Skip to content

Commit afb732d

Browse files
committed
only attach files if there are any and use the right url to get the quotedWareID
1 parent 2088422 commit afb732d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

utils/api/requests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export const createRequest = async ({ dynamicFormData, wareID, accessToken }) =>
241241
const url = () => accessToken ? `/wares/${wareID}/quote_groups.json` : null
242242
let { data, error } = await posting(url(), { pg_quote_group }, accessToken)
243243

244-
if (data && dynamicFormData.attachments) {
244+
if (data && dynamicFormData.attachments.length) {
245245
/**
246246
* TODO(alishaevn): I'm not sure why, but sometimes our data does not have the "quoted_ware_refs" property on it.
247247
* a search for the request in postman however, returns the property. we should find the underlying commonality on
@@ -250,8 +250,8 @@ export const createRequest = async ({ dynamicFormData, wareID, accessToken }) =>
250250
let quotedWareID = data.quoted_ware_refs?.[0]?.id
251251
if (!quotedWareID) {
252252
// we have to explicity use fetcher because "useOneRequest" is a hook
253-
const url = () => accessToken ? `quote_groups/${uuid}/quoted_wares/${quotedWareId}/purchase_orders.json` : null
254-
const res = await fetcher(`/quote_groups/${data.id}.json`, accessToken)
253+
const url = () => accessToken ? `/quote_groups/${data.id}.json` : null
254+
const res = await fetcher(url(), accessToken)
255255
quotedWareID = res.quoted_ware_refs?.[0]?.id
256256
}
257257

0 commit comments

Comments
 (0)