From c58c225a137e7d18bfcae21b6cc633dbdc342c51 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:08:37 +0700 Subject: [PATCH] =?UTF-8?q?refactor:=20=E0=B9=80=E0=B8=9E=E0=B8=B4?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=20fetchListMyBranch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/my-branch/index.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/stores/my-branch/index.ts b/src/stores/my-branch/index.ts index 97c11466..11d055da 100644 --- a/src/stores/my-branch/index.ts +++ b/src/stores/my-branch/index.ts @@ -8,6 +8,9 @@ import { Branch } from '../branch/types'; import useFlowStore from '../flow'; const useMyBranch = defineStore('useMyBranchStore', () => { + const myBranch = ref(); + const currentMyBranch = ref(); + const flowStore = useFlowStore(); async function fetchListOptionBranch< Options extends { @@ -52,8 +55,37 @@ const useMyBranch = defineStore('useMyBranchStore', () => { return false; } + async function fetchListMyBranch( + userId: string, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const res = await api.get>(`/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 { + myBranch, + currentMyBranch, + fetchListOptionBranch, + fetchListMyBranch, }; });