From 40fb7595d877ccd14f23f2c8d7be65011788523d Mon Sep 17 00:00:00 2001 From: Kariamos Date: Wed, 11 Feb 2026 15:56:20 +0100 Subject: [PATCH 1/3] fix(FormContent): update supplier creation logic to directly use supplier ID --- .../quote/sections/OtherCosts/index.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/pages/campaigns/quote/sections/OtherCosts/index.tsx b/src/pages/campaigns/quote/sections/OtherCosts/index.tsx index 02ffc9b4..05126d10 100644 --- a/src/pages/campaigns/quote/sections/OtherCosts/index.tsx +++ b/src/pages/campaigns/quote/sections/OtherCosts/index.tsx @@ -249,19 +249,18 @@ const FormContent = ({ campaignId }: { campaignId: string }) => { }} onCreateOption={async (inputValue: string) => { try { - const response = await createSupplier({ + const supplierId = await createSupplier({ campaign: campaignId, body: { name: inputValue }, + }) + .unwrap() + .then((res) => res.supplier_id); + + await refetchSuppliers(); + arrayHelpers.replace(index, { + ...item, + supplier: supplierId, }); - if ("data" in response) { - await refetchSuppliers(); - const newSupplierId = - (suppliers?.length || 0) + 1; - arrayHelpers.replace(index, { - ...item, - supplier: newSupplierId, - }); - } } catch (e) { console.error("Failed to create supplier:", e); } From ac26c93a2d511d3afc0d9466653fca9eea1f4eee Mon Sep 17 00:00:00 2001 From: Kariamos Date: Wed, 11 Feb 2026 16:35:58 +0100 Subject: [PATCH 2/3] fix(OtherCosts): update supplier options to use supplier ID instead of index --- src/pages/campaigns/quote/sections/OtherCosts/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/campaigns/quote/sections/OtherCosts/index.tsx b/src/pages/campaigns/quote/sections/OtherCosts/index.tsx index 05126d10..16623c56 100644 --- a/src/pages/campaigns/quote/sections/OtherCosts/index.tsx +++ b/src/pages/campaigns/quote/sections/OtherCosts/index.tsx @@ -68,8 +68,8 @@ const useSuppliers = ({ campaignId }: { campaignId: string }) => { const options = useMemo(() => { if (!data?.items) return []; - return data.items.map((item, index) => ({ - value: String(index + 1), + return data.items.map((item) => ({ + value: String(item.id), label: item.name, })); }, [data]); From 024b2ae04c3eeb2a045bd5b271460baeeea75a2e Mon Sep 17 00:00:00 2001 From: ZecD Date: Thu, 12 Feb 2026 09:54:28 +0100 Subject: [PATCH 3/3] fix(OtherCosts): update cost type options to use item ID instead of index --- src/pages/campaigns/quote/sections/OtherCosts/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/campaigns/quote/sections/OtherCosts/index.tsx b/src/pages/campaigns/quote/sections/OtherCosts/index.tsx index 16623c56..61fd4a7e 100644 --- a/src/pages/campaigns/quote/sections/OtherCosts/index.tsx +++ b/src/pages/campaigns/quote/sections/OtherCosts/index.tsx @@ -51,9 +51,9 @@ const useCostTypes = ({ campaignId }: { campaignId: string }) => { const options = useMemo(() => { if (!data?.items) return []; - return data.items.map((item, index) => ({ - value: String(index + 1), - label: item.name || `Type ${index + 1}`, + return data.items.map((item) => ({ + value: String(item.id), + label: item.name, })); }, [data]);