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

This commit is contained in:
Veronika Smirnova
2025-07-30 17:45:02 +03:00
parent 3e7ea13026
commit c3e84f0c49
6 changed files with 550 additions and 293 deletions

View File

@ -1,6 +1,6 @@
"use client";
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { useRouter } from "next/navigation";
import { useQuery, useMutation } from "@apollo/client";
import { Sidebar } from "@/components/dashboard/sidebar";
@ -54,6 +54,7 @@ interface FulfillmentConsumableProduct {
name: string;
description?: string;
price: number;
type?: "PRODUCT" | "CONSUMABLE";
category?: { name: string };
images: string[];
mainImage?: string;
@ -128,6 +129,36 @@ export function CreateFulfillmentConsumablesSupplyPage() {
)
: [];
// Отладочное логирование
React.useEffect(() => {
console.log("🛒 FULFILLMENT CONSUMABLES DEBUG:", {
selectedSupplier: selectedSupplier
? {
id: selectedSupplier.id,
name: selectedSupplier.name || selectedSupplier.fullName,
type: selectedSupplier.type,
}
: null,
productsLoading,
allProductsCount: productsData?.allProducts?.length || 0,
supplierProductsCount: supplierProducts.length,
allProducts:
productsData?.allProducts?.map((p) => ({
id: p.id,
name: p.name,
organizationId: p.organization.id,
organizationName: p.organization.name,
type: p.type || "NO_TYPE",
})) || [],
supplierProducts: supplierProducts.map((p) => ({
id: p.id,
name: p.name,
organizationId: p.organization.id,
organizationName: p.organization.name,
})),
});
}, [selectedSupplier, productsData, productsLoading, supplierProducts]);
const formatCurrency = (amount: number) => {
return new Intl.NumberFormat("ru-RU", {
style: "currency",
@ -363,7 +394,14 @@ export function CreateFulfillmentConsumablesSupplyPage() {
width: "calc((100% - 48px) / 7)", // 48px = 6 gaps * 8px each
animationDelay: `${index * 100}ms`,
}}
onClick={() => setSelectedSupplier(supplier)}
onClick={() => {
console.log("🔄 ВЫБРАН ПОСТАВЩИК:", {
id: supplier.id,
name: supplier.name || supplier.fullName,
type: supplier.type,
});
setSelectedSupplier(supplier);
}}
>
<div className="flex flex-col items-center justify-center h-full p-2 space-y-1">
<div className="relative">