From 40fb7595d877ccd14f23f2c8d7be65011788523d Mon Sep 17 00:00:00 2001 From: Kariamos Date: Wed, 11 Feb 2026 15:56:20 +0100 Subject: [PATCH] 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); }