From 03af965050c6890a1341e2f7709d62ff9a3f28f5 Mon Sep 17 00:00:00 2001 From: Veronika Smirnova Date: Mon, 28 Jul 2025 10:21:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=20=D1=82=D0=B8=D0=BF=D0=B0=20=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=20Product=20=D0=B8=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D1=85,=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=85=20=D0=B8=20Graph?= =?UTF-8?q?QL=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0=D1=85.=20=D0=A0?= =?UTF-8?q?=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=B2=D1=8B=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20=D1=82=D0=B8=D0=BF=D0=B0=20=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=20=D0=B2=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D1=84=D0=B5=D0=B9=D1=81=D0=B5,=20=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=80=D0=B5=D0=B7=D0=BE=D0=BB?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=8B=20=D0=B8=20=D1=82=D0=B8=D0=BF=D1=8B=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F.=20=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B8=20=D0=B8?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=82=D0=B8=D0=BF=D0=B0=20=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/schema.prisma | 6 ++ src/components/warehouse/product-card.tsx | 22 ++++- src/components/warehouse/product-form.tsx | 25 +++++ .../warehouse/warehouse-dashboard.tsx | 1 + src/graphql/mutations.ts | 2 + src/graphql/queries.ts | 1 + src/graphql/resolvers.ts | 95 ++++++++++--------- src/graphql/typedefs.ts | 12 ++- 8 files changed, 115 insertions(+), 49 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ab75f3c..00c9328 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -232,6 +232,7 @@ model Product { description String? price Decimal @db.Decimal(12, 2) quantity Int @default(0) + type ProductType @default(PRODUCT) categoryId String? brand String? color String? @@ -438,6 +439,11 @@ enum WildberriesSupplyStatus { CANCELLED } +enum ProductType { + PRODUCT + CONSUMABLE +} + model Logistics { id String @id @default(cuid()) fromLocation String diff --git a/src/components/warehouse/product-card.tsx b/src/components/warehouse/product-card.tsx index f27d5a4..0a1b23d 100644 --- a/src/components/warehouse/product-card.tsx +++ b/src/components/warehouse/product-card.tsx @@ -18,6 +18,7 @@ interface Product { description: string price: number quantity: number + type: 'PRODUCT' | 'CONSUMABLE' category: { id: string; name: string } | null brand: string color: string @@ -180,13 +181,26 @@ export function ProductCard({ product, onEdit, onDeleted }: ProductCardProps) { {/* Дополнительная информация */}
- {product.category && ( -
+
+ {/* Тип товара */} + + {product.type === 'PRODUCT' ? 'Товар' : 'Расходник'} + + + {/* Категория */} + {product.category && ( {product.category.name} -
- )} + )} +
{product.brand && ( diff --git a/src/components/warehouse/product-form.tsx b/src/components/warehouse/product-form.tsx index dfb874d..fef8b52 100644 --- a/src/components/warehouse/product-form.tsx +++ b/src/components/warehouse/product-form.tsx @@ -20,6 +20,7 @@ interface Product { description: string price: number quantity: number + type: 'PRODUCT' | 'CONSUMABLE' category: { id: string; name: string } | null brand: string color: string @@ -45,6 +46,7 @@ export function ProductForm({ product, onSave, onCancel }: ProductFormProps) { description: product?.description || '', price: product?.price || 0, quantity: product?.quantity || 0, + type: product?.type || 'PRODUCT' as 'PRODUCT' | 'CONSUMABLE', categoryId: product?.category?.id || 'none', brand: product?.brand || '', color: product?.color || '', @@ -183,6 +185,7 @@ export function ProductForm({ product, onSave, onCancel }: ProductFormProps) { description: formData.description || undefined, price: formData.price, quantity: formData.quantity, + type: formData.type, categoryId: formData.categoryId && formData.categoryId !== 'none' ? formData.categoryId : undefined, brand: formData.brand || undefined, color: formData.color || undefined, @@ -258,6 +261,28 @@ export function ProductForm({ product, onSave, onCancel }: ProductFormProps) { />
+
+ + +
+