diff --git a/src/stores/branch/index.ts b/src/stores/branch/index.ts index 4a851ba2..da27c519 100644 --- a/src/stores/branch/index.ts +++ b/src/stores/branch/index.ts @@ -150,20 +150,35 @@ const useBranchStore = defineStore('api-branch', () => { async function editById( id: string, - branch: Partial, + data: Partial, + qrCodeImage?: File, flow?: { sessionId: string; refTransactionId: string; transactionId: string; }, ) { - const res = await api.put(`/branch/${id}`, branch, { - headers: { - 'X-Session-Id': flow?.sessionId, - 'X-Rtid': flow?.refTransactionId, - 'X-Tid': flow?.transactionId, + const { ...payload } = data; + const res = await api.put( + `/branch/${id}`, + payload, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, }, - }); + ); + + if (qrCodeImage) { + await axios + .put(res.data.qrCodeImageUploadUrl, qrCodeImage, { + headers: { 'Content-Type': qrCodeImage.type }, + onUploadProgress: (e) => console.log(e), + }) + .catch((e) => console.error(e)); + } if (!res) return false;