|  |  |  | 
|---|
|  |  |  | import { useUserStore } from '@/store/modules/user'; | 
|---|
|  |  |  | import { UserUtils } from '@bole-core/core'; | 
|---|
|  |  |  | // import * as userRoleServices from '@/services/api/UserRole'; | 
|---|
|  |  |  | import { useQuery, useQueryClient } from '@tanstack/vue-query'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export function useIsSystemAdmin() { | 
|---|
|  |  |  | const userStore = useUserStore(); | 
|---|
|  |  |  | const { accountInfo } = storeToRefs(userStore); | 
|---|
|  |  |  | const isSystemAdmin = computed(() => UserUtils.isSystemRole(accountInfo.value)); | 
|---|
|  |  |  | return isSystemAdmin; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | import * as userServices from '@/services/api/user'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export function useUser() { | 
|---|
|  |  |  | const userStore = useUserStore(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { userId, userInfo } = storeToRefs(userStore); | 
|---|
|  |  |  | const { userId, userInfo, userDetail } = storeToRefs(userStore); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | user: userInfo, | 
|---|
|  |  |  | userId: userId, | 
|---|
|  |  |  | userDetail: userDetail, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | type UseUserInfoRolesOptions = { | 
|---|
|  |  |  | userInfoId: MaybeRef<string>; | 
|---|
|  |  |  | userType: EnumUserType; | 
|---|
|  |  |  | clientType: EnumClientType; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export function useUserInfoRoles({ userInfoId, userType, clientType }: UseUserInfoRolesOptions) { | 
|---|
|  |  |  | const { data: userInfoRoles } = useQuery({ | 
|---|
|  |  |  | queryKey: ['userServices/getUserInfoRoles'], | 
|---|
|  |  |  | queryFn: async () => { | 
|---|
|  |  |  | let res = await userServices.getUserInfoRoles( | 
|---|
|  |  |  | { | 
|---|
|  |  |  | userInfoId: unref(userInfoId), | 
|---|
|  |  |  | userType: userType, | 
|---|
|  |  |  | clientType: clientType, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { showLoading: false } | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | select(data) { | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | userInfoRoles, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|