From 93de8f8ae6ee20bd4a014a4f40d1a5f2b1cfea13 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:58:00 +0700 Subject: [PATCH] feat: update customer store attachment --- src/stores/customer/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/stores/customer/index.ts b/src/stores/customer/index.ts index d920b924..38d086e5 100644 --- a/src/stores/customer/index.ts +++ b/src/stores/customer/index.ts @@ -334,9 +334,9 @@ const useCustomerStore = defineStore('api-customer', () => { transactionId?: string; }, ) { - const { id, statusSave, code, ...playload } = data; + const { id, statusSave, code, file, ...payload } = data; - const res = await api.post('/customer-branch', playload, { + const res = await api.post('/customer-branch', payload, { headers: { 'X-Session-Id': flow?.sessionId, 'X-Rtid': flow?.refTransactionId || flowStore.rtid, @@ -345,6 +345,8 @@ const useCustomerStore = defineStore('api-customer', () => { }); if (!res) return false; + if (file) await addBranchAttachment(res.data.id, { file }); + return res.data; } @@ -357,11 +359,11 @@ const useCustomerStore = defineStore('api-customer', () => { transactionId?: string; }, ) { - const { code, branchNo, ...playload } = data; + const { code, branchNo, file, ...payload } = data; const res = await api.put( `/customer-branch/${id}`, - playload, + payload, { headers: { 'X-Session-Id': flow?.sessionId, @@ -370,6 +372,9 @@ const useCustomerStore = defineStore('api-customer', () => { }, }, ); + + if (file) await addBranchAttachment(id, { file }); + if (!res) return false; return res.data;