From e2b954965e593aefd9468b59ef34f80e8e780b82 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 10 Apr 2024 13:59:13 +0700 Subject: [PATCH] feat: branch userStats (store, type) --- src/stores/branch/index.ts | 25 +++++++++++++++++++++++++ src/stores/branch/types.ts | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/src/stores/branch/index.ts b/src/stores/branch/index.ts index 6c13dd48..0c00ed0d 100644 --- a/src/stores/branch/index.ts +++ b/src/stores/branch/index.ts @@ -225,6 +225,29 @@ const useBranchStore = defineStore('api-branch', () => { return false; } + async function userStats( + userType: string, + flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }, + ) { + const res = await api.get(`/branch/user-stats`, { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, + data: userType + }); + + if (!res) return false; + if (res.status === 200) return res.data; + + return false; + } + return { data, fetchList, @@ -237,6 +260,8 @@ const useBranchStore = defineStore('api-branch', () => { getUser, addUser, removeUser, + + userStats, }; }); diff --git a/src/stores/branch/types.ts b/src/stores/branch/types.ts index b914933d..e2c90d44 100644 --- a/src/stores/branch/types.ts +++ b/src/stores/branch/types.ts @@ -47,3 +47,10 @@ export type BranchCreate = { provinceId?: string | null; headOfficeId?: string | null; }; + +export type BranchUserStats = { + id: string, + nameEN: string, + name: string; + count: 0 +}