feat: userTypeStats (type, store)

This commit is contained in:
puriphatt 2024-04-10 14:00:19 +07:00
parent e2b954965e
commit 8e806c7c42
2 changed files with 31 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import {
import axios from 'axios';
const useUserStore = defineStore('api-user', () => {
const userStats = ref()
const data = ref<Pagination<User[]>>();
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,
};
});

View file

@ -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;
}