From 8e806c7c425495e44a90c95382e457aeb58b7ee1 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 10 Apr 2024 14:00:19 +0700 Subject: [PATCH] feat: userTypeStats (type, store) --- src/stores/user/index.ts | 22 ++++++++++++++++++++++ src/stores/user/types.ts | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/src/stores/user/index.ts b/src/stores/user/index.ts index 97171cc5..cbb68d6e 100644 --- a/src/stores/user/index.ts +++ b/src/stores/user/index.ts @@ -12,6 +12,7 @@ import { import axios from 'axios'; const useUserStore = defineStore('api-user', () => { + const userStats = ref() const data = ref>(); async function fetchAttachment( @@ -344,6 +345,25 @@ const useUserStore = defineStore('api-user', () => { return res.data || true; } + async function typeStats( + flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + },) { + const res = await api.get(`/user/type-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; + } + return { data, fetchList, @@ -360,6 +380,8 @@ const useUserStore = defineStore('api-user', () => { fetchAttachment, addAttachment, deleteAttachment, + + typeStats, }; }); diff --git a/src/stores/user/types.ts b/src/stores/user/types.ts index 4a55fd2c..3e3a895e 100644 --- a/src/stores/user/types.ts +++ b/src/stores/user/types.ts @@ -69,6 +69,8 @@ export type UserCreate = { userType: string; keycloakId: string; profileImage: File; + birthDate?: Date | null; + responsibleArea: string, }; export type UserAttachment = { @@ -83,3 +85,10 @@ export type UserAttachmentCreate = { export type UserAttachmentDelete = { file: string[]; }; + +export type UserTypeStats = { + USER: number; + MESSENGER: number; + DELEGATE: number; + AGENCY: number; +}