add set description in sell item
This commit is contained in:
@ -1155,6 +1155,7 @@ export async function sellItem(
|
||||
amount: number,
|
||||
price: number,
|
||||
server_ip: string,
|
||||
description: string,
|
||||
): Promise<{ status: string; operation_id: string }> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/marketplace/items/sell`, {
|
||||
method: 'POST',
|
||||
@ -1167,6 +1168,7 @@ export async function sellItem(
|
||||
amount,
|
||||
price,
|
||||
server_ip,
|
||||
description,
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@ -161,6 +161,8 @@ const PlayerInventory = React.forwardRef<PlayerInventoryHandle, PlayerInventoryP
|
||||
const [sellLoading, setSellLoading] = useState<boolean>(false);
|
||||
const [sellError, setSellError] = useState<string | null>(null);
|
||||
|
||||
const [description, setDescription] = useState('');
|
||||
|
||||
// Функция для запроса инвентаря игрока
|
||||
const fetchPlayerInventory = async () => {
|
||||
try {
|
||||
@ -256,6 +258,7 @@ const PlayerInventory = React.forwardRef<PlayerInventoryHandle, PlayerInventoryP
|
||||
amount,
|
||||
price,
|
||||
serverIp,
|
||||
description,
|
||||
);
|
||||
|
||||
// Проверяем статус операции
|
||||
@ -503,6 +506,15 @@ const PlayerInventory = React.forwardRef<PlayerInventoryHandle, PlayerInventoryP
|
||||
sx={INPUT_SX}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
label="Описание (необязательно)"
|
||||
fullWidth
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
inputProps={{ min: 1 }}
|
||||
sx={INPUT_SX}
|
||||
/>
|
||||
|
||||
{sellError && (
|
||||
<Box
|
||||
sx={{
|
||||
|
||||
@ -635,7 +635,7 @@ export default function Marketplace() {
|
||||
|
||||
const hasItemMeta = (item: MarketplaceItemResponse) => {
|
||||
const meta = item.item_data;
|
||||
if (!meta) return false;
|
||||
// if (!meta) return false;
|
||||
|
||||
// базовые поля, которые НЕ считаем метой
|
||||
const baseKeys = ['slot', 'material', 'amount'];
|
||||
@ -643,6 +643,12 @@ export default function Marketplace() {
|
||||
return Object.keys(meta).some((key) => !baseKeys.includes(key));
|
||||
};
|
||||
|
||||
const hasItemDetails = (item: MarketplaceItemResponse) => {
|
||||
return Boolean(
|
||||
hasItemMeta(item) || item.description
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
const statusChip = useMemo(() => {
|
||||
if (statusLoading) {
|
||||
@ -892,14 +898,15 @@ export default function Marketplace() {
|
||||
<DialogContent dividers sx={DIALOG_DIVIDERS_SX}>
|
||||
{metaItem && (() => {
|
||||
const meta = getItemMeta(metaItem);
|
||||
if (!meta) return null;
|
||||
|
||||
const enchants = formatEnchants(meta.enchants);
|
||||
const enchants = meta ? formatEnchants(meta.enchants) : [];
|
||||
|
||||
const filteredMeta = Object.entries(meta).filter(([key]) =>
|
||||
key !== 'enchants' &&
|
||||
metaKeyMatchesSearch(key, metaSearch)
|
||||
);
|
||||
const filteredMeta = meta
|
||||
? Object.entries(meta).filter(([key]) =>
|
||||
key !== 'enchants' &&
|
||||
metaKeyMatchesSearch(key, metaSearch)
|
||||
)
|
||||
: [];
|
||||
|
||||
return (
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '1vw' }}>
|
||||
@ -961,15 +968,18 @@ export default function Marketplace() {
|
||||
)}
|
||||
|
||||
{/* SEARCH */}
|
||||
<TextField
|
||||
placeholder="Поиск по метаданным..."
|
||||
value={metaSearch}
|
||||
onChange={(e) => setMetaSearch(e.target.value)}
|
||||
fullWidth
|
||||
sx={PRICE_FIELD_SX}
|
||||
/>
|
||||
|
||||
<Divider sx={{mt: '0.7vw'}} />
|
||||
{meta && Object.keys(meta).length > 0 && (
|
||||
<Box>
|
||||
<TextField
|
||||
placeholder="Поиск по метаданным..."
|
||||
value={metaSearch}
|
||||
onChange={(e) => setMetaSearch(e.target.value)}
|
||||
fullWidth
|
||||
sx={PRICE_FIELD_SX}
|
||||
/>
|
||||
<Divider sx={{mt: '2vw'}} />
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* ENCHANTS */}
|
||||
{enchants && (
|
||||
@ -1372,7 +1382,7 @@ export default function Marketplace() {
|
||||
}}
|
||||
>
|
||||
{/* INFO BUTTON */}
|
||||
{hasItemMeta(item) && (
|
||||
{hasItemDetails(item) && (
|
||||
<IconButton
|
||||
onClick={() => openMetaDialog(item)}
|
||||
size="small"
|
||||
|
||||
Reference in New Issue
Block a user