From 416683b3d7d524b001daf4142bd345999792249d Mon Sep 17 00:00:00 2001 From: fatemeh sane Date: Wed, 7 Oct 2026 12:23:42 +0330 Subject: [PATCH] fix: resolve typescript configs and finish merge --- frontend/src/lib/api.ts | 22 ----------- frontend/src/pages/Units/UnitsPage.tsx | 54 -------------------------- 2 files changed, 76 deletions(-) diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 12cdb7a..93bf2a8 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -458,16 +458,9 @@ function adaptBrandLink(raw: RawBrandLink): BrandLinkRow { return { id: raw.id, brand_id: raw.brand_id, brand_name: raw.brand?.name || "" }; } -<<<<<<< Updated upstream -// تأمین‌کنندگان متصل به یک متریال — پاسخ GET /materials/{id}/suppliers -// Raw shape mirrors the backend dict exactly: clean supplier objects produced -// by an atomic JOIN (select(Supplier).join(SupplierMaterial)…) — the name -// always comes from the suppliers table, never from the material row. -======= // ── تأمین‌کننده‌های متریال — پاسخ GET /materials/{id}/suppliers ────────────── // Raw shape mirrors the backend dict exactly. The backend uses an atomic // column-level JOIN so `name` always comes from the suppliers table. ->>>>>>> Stashed changes interface RawMaterialSupplier { id: string; name: string; @@ -488,11 +481,6 @@ export interface MaterialSupplier { function adaptMaterialSupplier(raw: RawMaterialSupplier): MaterialSupplier { return { id: raw.id, -<<<<<<< Updated upstream - // Bound straight from the supplier object in the API response — there is - // no fallback, so a supplier row can never render the material's name. -======= ->>>>>>> Stashed changes name: raw.name, phone: raw.phone, contact_person: raw.contact_person, @@ -1168,20 +1156,10 @@ export const api = { updateCanonicalUnit: async (id: string, canonical_unit_id: number): Promise => { await patchData(`/materials/${id}`, { canonical_unit_id }); }, -<<<<<<< Updated upstream - // فهرست تأمین‌کننده‌های متصل به یک متریال (GET /materials/{id}/suppliers) - listSuppliers: async (materialId: string): Promise => { - // The backend returns { data: [...clean supplier objects] } from an - // atomic JOIN; getData unwraps the envelope. No fallback data — - // an empty array means the material genuinely has no suppliers. - const raw = await getData( - `/materials/${materialId}/suppliers`, -======= // فهرست تأمین‌کننده‌های متصل به یک متریال — GET /materials/{id}/suppliers listSuppliers: async (materialId: string): Promise => { const raw = await getData( `/materials/${materialId}/suppliers?page_size=100`, ->>>>>>> Stashed changes ); return raw.map(adaptMaterialSupplier); }, diff --git a/frontend/src/pages/Units/UnitsPage.tsx b/frontend/src/pages/Units/UnitsPage.tsx index 9b231bc..b9c7c08 100644 --- a/frontend/src/pages/Units/UnitsPage.tsx +++ b/frontend/src/pages/Units/UnitsPage.tsx @@ -104,16 +104,10 @@ export function UnitsPage() { const [rowsLoading, setRowsLoading] = useState(false); const [brandLinks, setBrandLinks] = useState([]); -<<<<<<< Updated upstream - // تأمین‌کننده‌های متریال انتخاب‌شده — type imported from api.ts - const [materialSuppliers, setMaterialSuppliers] = useState([]); - const [suppliersLoading, setSuppliersLoading] = useState(false); -======= // تأمین‌کننده‌های متریال انتخاب‌شده — داده از GET /materials/{id}/suppliers const [materialSuppliers, setMaterialSuppliers] = useState([]); const [suppliersLoading, setSuppliersLoading] = useState(false); // کلید پیشگیری از flicker: قبل از رسیدن پاسخ جدید، empty state نشان نمی‌دهیم ->>>>>>> Stashed changes const [suppliersLoadedId, setSuppliersLoadedId] = useState(null); // واحدها و برندهای سراسری (فهرست دیتابیس) @@ -289,11 +283,7 @@ export function UnitsPage() { setSuppliersLoading(true); api.materials .listSuppliers(materialId) -<<<<<<< Updated upstream - .then((list) => { -======= .then((list) => { ->>>>>>> Stashed changes if (alive) { setMaterialSuppliers(list); setSuppliersLoadedId(materialId); @@ -303,13 +293,7 @@ export function UnitsPage() { if (!alive) return; setMaterialSuppliers([]); setSuppliersLoadedId(materialId); -<<<<<<< Updated upstream - // Surface the real error so backend issues are not silently hidden - const msg = err instanceof Error ? err.message : "خواندن تأمین‌کننده‌های متریال ناموفق بود"; - toast.error(msg); -======= toast.error(err instanceof Error ? err.message : "خواندن تأمین‌کننده‌های متریال ناموفق بود"); ->>>>>>> Stashed changes }) .finally(() => { if (alive) setSuppliersLoading(false); }); return () => { alive = false; }; @@ -598,43 +582,6 @@ export function UnitsPage() { ) : ( <> -<<<<<<< Updated upstream - {/* تامین‌کنندگان متریال — پاسخ GET /materials/{id}/suppliers */} -
-
-

- تامین‌کنندگان متریال -

-
-
- {suppliersLoading || materialId !== suppliersLoadedId ? ( -
-
-
- ) : materialSuppliers.length === 0 ? ( -
- تامین‌کننده‌ای برای این متریال ثبت نشده است -
- ) : ( -
- {materialSuppliers.map((s) => ( -
- {/* نام تأمین‌کننده — مستقیم از پاسخ API، بدون fallback */} -
- - {s.name} -
- {(s.location || s.phone || s.contact_person) && ( -
- {s.location && {s.location}} - {s.phone && {s.phone}} - {s.contact_person && {s.contact_person}} -
- )} -======= {/* ── تامین‌کنندگان متریال ── */}
{/* سرصفحه — همیشه نمایش داده می‌شود */} @@ -699,7 +646,6 @@ export function UnitsPage() { {s.location || ثبت نشده}
->>>>>>> Stashed changes
))}