Skip to content

Commit 0306bbd

Browse files
authored
Merge pull request #216 from AppQuality/fix-bug-supplier-creation
fix(FormContent): update supplier creation logic to directly use supp…
2 parents 7f23b43 + 40fb759 commit 0306bbd

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

  • src/pages/campaigns/quote/sections/OtherCosts

src/pages/campaigns/quote/sections/OtherCosts/index.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,19 +249,18 @@ const FormContent = ({ campaignId }: { campaignId: string }) => {
249249
}}
250250
onCreateOption={async (inputValue: string) => {
251251
try {
252-
const response = await createSupplier({
252+
const supplierId = await createSupplier({
253253
campaign: campaignId,
254254
body: { name: inputValue },
255+
})
256+
.unwrap()
257+
.then((res) => res.supplier_id);
258+
259+
await refetchSuppliers();
260+
arrayHelpers.replace(index, {
261+
...item,
262+
supplier: supplierId,
255263
});
256-
if ("data" in response) {
257-
await refetchSuppliers();
258-
const newSupplierId =
259-
(suppliers?.length || 0) + 1;
260-
arrayHelpers.replace(index, {
261-
...item,
262-
supplier: newSupplierId,
263-
});
264-
}
265264
} catch (e) {
266265
console.error("Failed to create supplier:", e);
267266
}

0 commit comments

Comments
 (0)