diff --git a/src/stores/branch/index.ts b/src/stores/branch/index.ts index fedf3cb5..4ebe8fab 100644 --- a/src/stores/branch/index.ts +++ b/src/stores/branch/index.ts @@ -226,6 +226,28 @@ const useBranchStore = defineStore('api-branch', () => { return false; } + async function stats(flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }) { + const res = await api.get<{ + hq: number; + br: number; + }>(`/branch/stats`, { + 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; + + return false; + } + async function userStats( userType: string, flow?: { @@ -234,14 +256,16 @@ const useBranchStore = defineStore('api-branch', () => { transactionId: string; }, ) { - const res = await api.get(`/branch/user-stats`, { - headers: { - 'X-Session-Id': flow?.sessionId, - 'X-Rtid': flow?.refTransactionId, - 'X-Tid': flow?.transactionId, + const res = await api.get( + `/branch/user-stats${userType ? '?'.concat(userType) : ''}`, + { + 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; @@ -262,6 +286,7 @@ const useBranchStore = defineStore('api-branch', () => { addUser, removeUser, + stats, userStats, }; });