From 54482648d45209b8b196bb0ce3149cc3f748ceb0 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:47:18 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20params=20=E0=B9=83=E0=B8=99=20fetchList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/branch/index.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/stores/branch/index.ts b/src/stores/branch/index.ts index c2b91b4f..6c13dd48 100644 --- a/src/stores/branch/index.ts +++ b/src/stores/branch/index.ts @@ -52,21 +52,31 @@ const useBranchStore = defineStore('api-branch', () => { return false; } - async function fetchById( + async function fetchById( id: string, + opts?: { includeSubBranch?: boolean }, flow?: { sessionId: string; refTransactionId: string; transactionId: string; }, ) { - const res = await api.get(`/branch/${id}`, { - headers: { - 'X-Session-Id': flow?.sessionId, - 'X-Rtid': flow?.refTransactionId, - 'X-Tid': flow?.transactionId, + const params = new URLSearchParams(); + + if (opts?.includeSubBranch) params.append('includeSubBranch', 'true'); + + const query = params.toString(); + + const res = await api.get( + `/branch/${id}${(params && '?'.concat(query)) || ''}`, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, }, - }); + ); if (!res) return false; if (res.status === 200) return res.data;