update goods
This commit is contained in:
@@ -14,7 +14,6 @@ export async function fetchPublicProducts(params?: {
|
||||
categorySlug?: string
|
||||
q?: string
|
||||
sort?: 'price_asc' | 'price_desc' | ''
|
||||
availability?: 'all' | 'in_stock' | 'made_to_order'
|
||||
page?: number
|
||||
pageSize?: number
|
||||
priceMinCents?: number
|
||||
@@ -25,7 +24,6 @@ export async function fetchPublicProducts(params?: {
|
||||
categorySlug: params?.categorySlug || undefined,
|
||||
q: params?.q || undefined,
|
||||
sort: params?.sort || undefined,
|
||||
availability: params?.availability || undefined,
|
||||
page: params?.page || undefined,
|
||||
pageSize: params?.pageSize || undefined,
|
||||
priceMin: params?.priceMinCents ?? undefined,
|
||||
@@ -55,16 +53,13 @@ export async function createProduct(body: {
|
||||
slug?: string
|
||||
shortDescription?: string | null
|
||||
description?: string | null
|
||||
quantity?: number | null
|
||||
quantity: number
|
||||
materials?: string[]
|
||||
priceCents: number
|
||||
imageUrl?: string | null
|
||||
imageUrls?: string[]
|
||||
published: boolean
|
||||
inStock?: boolean
|
||||
leadTimeDays?: number | null
|
||||
/** Пустая строка / отсутствует — категория «Не указано» на сервере */
|
||||
categoryId?: string
|
||||
categoryId: string
|
||||
}): Promise<Product> {
|
||||
const { data } = await apiClient.post<Product>('admin/products', body)
|
||||
return data
|
||||
@@ -77,15 +72,13 @@ export async function updateProduct(
|
||||
slug: string
|
||||
shortDescription: string | null
|
||||
description: string | null
|
||||
quantity: number | null
|
||||
quantity: number
|
||||
materials: string[]
|
||||
priceCents: number
|
||||
imageUrl: string | null
|
||||
imageUrls: string[]
|
||||
published: boolean
|
||||
inStock: boolean
|
||||
leadTimeDays: number | null
|
||||
categoryId?: string
|
||||
categoryId: string
|
||||
}>,
|
||||
): Promise<Product> {
|
||||
const { data } = await apiClient.patch<Product>(`admin/products/${id}`, body)
|
||||
|
||||
@@ -23,8 +23,6 @@ export type Product = {
|
||||
imageUrl: string | null
|
||||
imageUrls?: string[] // legacy-friendly (used only in admin payloads)
|
||||
published: boolean
|
||||
inStock: boolean
|
||||
leadTimeDays: number | null
|
||||
categoryId: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
|
||||
@@ -44,12 +44,7 @@ export function ProductCard({ product, mediaHeight = 200, actions }: Props) {
|
||||
navigate(`/products/${product.id}`)
|
||||
}, [navigate, product.id])
|
||||
|
||||
const stockLabel =
|
||||
product.inStock && product.quantity === 0
|
||||
? { label: 'Нет в наличии', color: 'default' as const }
|
||||
: !product.inStock
|
||||
? { label: `Под заказ · ${product.leadTimeDays ?? '—'} дн.`, color: 'warning' as const }
|
||||
: null
|
||||
const stockLabel = product.quantity > 0 ? null : { label: 'Нет в наличии', color: 'default' as const }
|
||||
|
||||
return (
|
||||
<Card
|
||||
@@ -132,7 +127,7 @@ export function ProductCard({ product, mediaHeight = 200, actions }: Props) {
|
||||
label={stockLabel.label}
|
||||
size="small"
|
||||
color={stockLabel.color}
|
||||
variant={stockLabel.color === 'warning' ? 'outlined' : 'filled'}
|
||||
variant="filled"
|
||||
sx={{
|
||||
position: 'absolute',
|
||||
top: 8,
|
||||
@@ -140,8 +135,8 @@ export function ProductCard({ product, mediaHeight = 200, actions }: Props) {
|
||||
fontWeight: 600,
|
||||
fontSize: '0.7rem',
|
||||
backdropFilter: 'blur(4px)',
|
||||
bgcolor: stockLabel.color === 'default' ? 'rgba(0,0,0,0.55)' : undefined,
|
||||
color: stockLabel.color === 'default' ? 'common.white' : undefined,
|
||||
bgcolor: 'rgba(0,0,0,0.55)',
|
||||
color: 'common.white',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user