File tree Expand file tree Collapse file tree
src/pages/campaigns/quote/sections/OtherCosts Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments