feat: update customer store attachment

This commit is contained in:
Methapon2001 2024-08-08 14:58:00 +07:00
parent 3f7fd7c3cd
commit 93de8f8ae6

View file

@ -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<CustomerBranch>('/customer-branch', playload, {
const res = await api.post<CustomerBranch>('/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<CustomerBranch>(
`/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;