From b1f78a34e232805fa5ed78dd79faf79aaad162e4 Mon Sep 17 00:00:00 2001 From: Veronika Smirnova Date: Thu, 24 Jul 2025 12:48:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=20CreateConsumablesSupplyPage:=20=D1=83=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D1=88=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B8=20=D1=80=D0=B0=D1=81=D1=85=D0=BE=D0=B4=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D1=8B=20=D0=B8=D0=BD?= =?UTF-8?q?=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=D0=B0=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B0=20=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B8=D1=81=D0=BA=D0=B0.=20=D0=9E=D0=BF=D1=82=D0=B8?= =?UTF-8?q?=D0=BC=D0=B8=D0=B7=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=20=D0=B8=20=D1=83=D0=BB=D1=83=D1=87=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=81=D1=82=D0=B8=D0=BB=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B2=D1=8B=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=83=D0=B4=D0=BE=D0=B1=D1=81=D1=82=D0=B2=D0=B0=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B0=D1=85=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BE=D0=B1=D1=8F=D0=B7=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D1=85=20=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../create-consumables-supply-page.tsx | 716 +++++++++--------- 1 file changed, 347 insertions(+), 369 deletions(-) diff --git a/src/components/supplies/create-consumables-supply-page.tsx b/src/components/supplies/create-consumables-supply-page.tsx index 9b61ae4..9ce164d 100644 --- a/src/components/supplies/create-consumables-supply-page.tsx +++ b/src/components/supplies/create-consumables-supply-page.tsx @@ -200,7 +200,11 @@ export function CreateConsumablesSupplyPage() { }; const handleCreateSupply = async () => { - if (!selectedSupplier || selectedConsumables.length === 0 || !deliveryDate) { + if ( + !selectedSupplier || + selectedConsumables.length === 0 || + !deliveryDate + ) { toast.error("Заполните все обязательные поля"); return; } @@ -226,7 +230,8 @@ export function CreateConsumablesSupplyPage() { router.push("/supplies"); } else { toast.error( - result.data?.createSupplyOrder?.message || "Ошибка при создании поставки" + result.data?.createSupplyOrder?.message || + "Ошибка при создании поставки" ); } } catch (error) { @@ -237,265 +242,6 @@ export function CreateConsumablesSupplyPage() { } }; - // Если выбран поставщик, показываем его товары - if (selectedSupplier) { - return ( -
- -
-
- {/* Заголовок с навигацией */} -
-
- -
-

- Расходники поставщика -

-

- {selectedSupplier.name || selectedSupplier.fullName} -

-
-
- -
- - {/* Поиск по товарам */} -
-
- - setProductSearchQuery(e.target.value)} - className="bg-white/10 border-white/20 text-white placeholder-white/40 pl-10" - /> -
-
- - {/* Основной контент */} -
- {/* Список товаров */} -
- {productsLoading ? ( -
-

Загрузка расходников...

-
- ) : supplierProducts.length === 0 ? ( -
- -

- У данного поставщика нет доступных расходников -

-
- ) : ( -
- {supplierProducts.map((product: ConsumableProduct) => { - const selectedQuantity = getSelectedQuantity(product.id); - return ( - -
- {/* Изображение товара */} -
- {product.images && product.images.length > 0 ? ( - {product.name} - ) : ( -
- -
- )} -
- - {/* Информация о товаре */} -
-

- {product.name} -

- {product.category && ( - - {product.category.name} - - )} -

- {product.description || "Описание отсутствует"} -

-
- - {formatCurrency(product.price)} - {product.unit && ( - - / {product.unit} - - )} - - {product.stock && ( - - В наличии: {product.stock} - - )} -
-
- - {/* Управление количеством */} -
-
- - - {selectedQuantity} - - -
- {selectedQuantity > 0 && ( - - {formatCurrency( - product.price * selectedQuantity - )} - - )} -
-
-
- ); - })} -
- )} -
- - {/* Корзина */} - {selectedConsumables.length > 0 && ( -
- -

- - Корзина ({getTotalItems()} шт) -

- -
- {selectedConsumables.map((consumable) => ( -
-
-

- {consumable.name} -

-

- {formatCurrency(consumable.price)} ×{" "} - {consumable.selectedQuantity} -

-
-
- - {formatCurrency( - consumable.price * consumable.selectedQuantity - )} - - -
-
- ))} -
- -
-
- - setDeliveryDate(e.target.value)} - className="bg-white/10 border-white/20 text-white" - min={new Date().toISOString().split('T')[0]} - required - /> -
-
- Итого: - - {formatCurrency(getTotalAmount())} - -
- -
-
-
- )} -
-
-
-
- ); - } - - // Показываем список поставщиков return (
@@ -510,7 +256,7 @@ export function CreateConsumablesSupplyPage() { Создание поставки расходников

- Выберите поставщика расходников для создания поставки + Выберите поставщика и добавьте расходники в заказ

+ )} + +
+ + setSearchQuery(e.target.value)} + className="bg-white/10 border-white/20 text-white placeholder-white/40 pl-10" + /> +
+ + +
+ {counterpartiesLoading ? ( +
+
+

Загрузка поставщиков...

- - ))} + ) : filteredSuppliers.length === 0 ? ( +
+ +

+ {searchQuery + ? "Поставщики не найдены" + : "У вас пока нет партнеров-поставщиков расходников"} +

+
+ ) : ( +
+ {filteredSuppliers.map((supplier: ConsumableSupplier) => ( + setSelectedSupplier(supplier)} + > +
+ ({ + id: user.id, + avatar: user.avatar, + })), + }} + size="sm" + /> +
+

+ {supplier.name || + supplier.fullName || + "Поставщик"} +

+
+ {renderStars(4.5)} + + 4.5 + +
+

+ ИНН: {supplier.inn} +

+
+ {selectedSupplier?.id === supplier.id && ( +
+ + Выбран + +
+ )} +
+
+ ))} +
+ )} +
+ + + {/* Блок "Расходники" */} + +
+
+

+ + Расходники + {selectedSupplier && ( + + - {selectedSupplier.name || selectedSupplier.fullName} + + )} +

+
+ {selectedSupplier && ( +
+ + setProductSearchQuery(e.target.value)} + className="bg-white/10 border-white/20 text-white placeholder-white/40 pl-10" + /> +
+ )} +
+ +
+ {!selectedSupplier ? ( +
+ +

+ Выберите поставщика для просмотра расходников +

+
+ ) : productsLoading ? ( +
+
+

Загрузка расходников...

+
+ ) : supplierProducts.length === 0 ? ( +
+ +

+ У данного поставщика нет доступных расходников +

+
+ ) : ( +
+ {supplierProducts.map((product: ConsumableProduct) => { + const selectedQuantity = getSelectedQuantity( + product.id + ); + return ( + +
+ {/* Изображение товара */} +
+ {product.images && product.images.length > 0 ? ( + {product.name} + ) : ( +
+ +
+ )} +
+ + {/* Информация о товаре */} +
+

+ {product.name} +

+ {product.category && ( + + {product.category.name} + + )} +

+ {product.description || + "Описание отсутствует"} +

+
+ + {formatCurrency(product.price)} + {product.unit && ( + + / {product.unit} + + )} + + {product.stock && ( + + В наличии: {product.stock} + + )} +
+
+ + {/* Управление количеством */} +
+
+ + + {selectedQuantity} + + +
+ {selectedQuantity > 0 && ( + + {formatCurrency( + product.price * selectedQuantity + )} + + )} +
+
+
+ ); + })} +
+ )} +
+
+ + + {/* Правая колонка - Корзина */} + {selectedConsumables.length > 0 && ( +
+ +

+ + Корзина ({getTotalItems()} шт) +

+ +
+ {selectedConsumables.map((consumable) => ( +
+
+

+ {consumable.name} +

+

+ {formatCurrency(consumable.price)} ×{" "} + {consumable.selectedQuantity} +

+
+
+ + {formatCurrency( + consumable.price * consumable.selectedQuantity + )} + + +
+
+ ))} +
+ +
+
+ + setDeliveryDate(e.target.value)} + className="bg-white/10 border-white/20 text-white" + min={new Date().toISOString().split("T")[0]} + required + /> +
+
+ Итого: + + {formatCurrency(getTotalAmount())} + +
+ +
+
)}