Добавлено новое поле типа товара в модель Product и соответствующие изменения в компонентах, формах и GraphQL запросах. Реализована логика выбора типа товара в интерфейсе, обновлены резолверы и типы для поддержки нового поля. Улучшена обработка данных и интерфейс для отображения типа товара.

This commit is contained in:
Veronika Smirnova
2025-07-28 10:21:22 +03:00
parent 9f84316e00
commit 03af965050
8 changed files with 115 additions and 49 deletions

View File

@ -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) {
{/* Дополнительная информация */}
<div className="space-y-1">
{product.category && (
<div className="flex items-center gap-2">
<div className="flex items-center gap-2 flex-wrap">
{/* Тип товара */}
<Badge
variant="outline"
className={`text-xs ${
product.type === 'PRODUCT'
? 'bg-blue-500/20 text-blue-300 border-blue-400/30'
: 'bg-orange-500/20 text-orange-300 border-orange-400/30'
}`}
>
{product.type === 'PRODUCT' ? 'Товар' : 'Расходник'}
</Badge>
{/* Категория */}
{product.category && (
<Badge variant="outline" className="glass-secondary text-white/60 border-white/20 text-xs">
{product.category.name}
</Badge>
</div>
)}
)}
</div>
<div className="flex flex-wrap gap-1">
{product.brand && (

View File

@ -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) {
/>
</div>
<div className="mt-4">
<Label className="text-white/80 text-sm mb-2 block">
Тип <span className="text-red-400">*</span>
</Label>
<Select
value={formData.type}
onValueChange={(value) => handleInputChange('type', value)}
>
<SelectTrigger className="glass-input text-white h-10">
<SelectValue placeholder="Выберите тип" />
</SelectTrigger>
<SelectContent className="glass-card">
<SelectItem value="PRODUCT" className="text-white">
Товар
</SelectItem>
<SelectItem value="CONSUMABLE" className="text-white">
Расходник
</SelectItem>
</SelectContent>
</Select>
</div>
<div className="grid grid-cols-2 gap-4 mt-4">
<div>
<Label className="text-white/80 text-sm mb-2 block">

View File

@ -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