refactor: เพิ่ม fetchListMyBranch
This commit is contained in:
parent
965b268c44
commit
c58c225a13
1 changed files with 32 additions and 0 deletions
|
|
@ -8,6 +8,9 @@ import { Branch } from '../branch/types';
|
||||||
import useFlowStore from '../flow';
|
import useFlowStore from '../flow';
|
||||||
|
|
||||||
const useMyBranch = defineStore('useMyBranchStore', () => {
|
const useMyBranch = defineStore('useMyBranchStore', () => {
|
||||||
|
const myBranch = ref<Branch[]>();
|
||||||
|
const currentMyBranch = ref<Branch>();
|
||||||
|
|
||||||
const flowStore = useFlowStore();
|
const flowStore = useFlowStore();
|
||||||
async function fetchListOptionBranch<
|
async function fetchListOptionBranch<
|
||||||
Options extends {
|
Options extends {
|
||||||
|
|
@ -52,8 +55,37 @@ const useMyBranch = defineStore('useMyBranchStore', () => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchListMyBranch(
|
||||||
|
userId: string,
|
||||||
|
flow?: {
|
||||||
|
sessionId?: string;
|
||||||
|
refTransactionId?: string;
|
||||||
|
transactionId?: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const res = await api.get<Pagination<Branch[]>>(`/user/${userId}/branch`, {
|
||||||
|
headers: {
|
||||||
|
'X-Session-Id': flow?.sessionId,
|
||||||
|
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||||
|
'X-Tid': flow?.transactionId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res) return false;
|
||||||
|
if (res.status === 200) {
|
||||||
|
myBranch.value = res.data.result;
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
myBranch,
|
||||||
|
currentMyBranch,
|
||||||
|
|
||||||
fetchListOptionBranch,
|
fetchListOptionBranch,
|
||||||
|
fetchListMyBranch,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue