refactor: get api employee by branchId
This commit is contained in:
parent
b389185a20
commit
48fdf71522
1 changed files with 40 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from './types';
|
||||
import axios from 'axios';
|
||||
import useFlowStore from '../flow';
|
||||
import { Employee } from '../employee/types';
|
||||
|
||||
const useCustomerStore = defineStore('api-customer', () => {
|
||||
const flowStore = useFlowStore();
|
||||
|
|
@ -52,6 +53,43 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function fetchBranchEmployee(
|
||||
idBranch: string,
|
||||
opts?: {
|
||||
zipCode?: string;
|
||||
query?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
},
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const params = new URLSearchParams();
|
||||
for (const [k, v] of Object.entries(opts || {})) {
|
||||
v !== undefined && params.append(k, v.toString());
|
||||
}
|
||||
|
||||
const query = params.toString();
|
||||
|
||||
const res = await api.get<Pagination<Employee[]>>(
|
||||
`/customer-branch/${idBranch}/employee${(params && '?'.concat(query)) || ''}`,
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (res.status === 200) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchListCustomeBranch<
|
||||
Options extends {
|
||||
zipCode?: string;
|
||||
|
|
@ -499,6 +537,8 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
editBranchById,
|
||||
deleteBranchById,
|
||||
fetchListCustomeBranchById,
|
||||
|
||||
fetchBranchEmployee,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue