refactor: ลบ code ออก ตอนส่ง
This commit is contained in:
parent
2d4ecfebba
commit
472d477d7e
1 changed files with 23 additions and 13 deletions
|
|
@ -28,16 +28,15 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.get<Customer & { branch: CustomerBranch[] }>(
|
||||
`/customer/${customerId}`,
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
const res = await api.get<
|
||||
Customer & { branch: CustomerBranch[]; registeredBranchId: string }
|
||||
>(`/customer/${customerId}`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
|
|
@ -46,7 +45,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function fetchListBranch<
|
||||
async function fetchListCustomeBranch<
|
||||
Options extends {
|
||||
zipCode?: string;
|
||||
customerId?: string;
|
||||
|
|
@ -173,8 +172,14 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
},
|
||||
) {
|
||||
const { image, ...payload } = data;
|
||||
|
||||
const attachment = payload.customerBranch?.map((v) => v.file);
|
||||
|
||||
payload.customerBranch = payload.customerBranch?.map((v) => {
|
||||
delete v['code'];
|
||||
return { ...v };
|
||||
});
|
||||
|
||||
if (payload.customerBranch?.length) {
|
||||
for (let i = 0; i < payload.customerBranch?.length; i++) {
|
||||
delete payload.customerBranch[i].file;
|
||||
|
|
@ -227,6 +232,11 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
const { image, ...payload } = data;
|
||||
const attachment = payload.customerBranch?.map((v) => v.file);
|
||||
|
||||
payload.customerBranch = payload.customerBranch?.map((v) => {
|
||||
const { code, ...rest } = v;
|
||||
return { ...rest };
|
||||
});
|
||||
|
||||
if (payload.customerBranch?.length) {
|
||||
for (let i = 0; i < payload.customerBranch?.length; i++) {
|
||||
delete payload.customerBranch[i].file;
|
||||
|
|
@ -424,7 +434,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
);
|
||||
}
|
||||
|
||||
async function fetchListBranchById(
|
||||
async function fetchListCustomeBranchById(
|
||||
branchId: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
|
|
@ -452,7 +462,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
|
||||
getStatsCustomer,
|
||||
|
||||
fetchListBranch,
|
||||
fetchListCustomeBranch,
|
||||
fetchListById,
|
||||
fetchList,
|
||||
create,
|
||||
|
|
@ -461,7 +471,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
createBranch,
|
||||
editBranchById,
|
||||
deleteBranchById,
|
||||
fetchListBranchById,
|
||||
fetchListCustomeBranchById,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue