Adding a ton of stuff

This commit is contained in:
2026-07-17 04:39:18 -07:00
parent 8d9fe8e75d
commit de28a67417
63 changed files with 2027 additions and 613 deletions
+15
View File
@@ -1,7 +1,9 @@
import { computed, reactive, toRefs } from "vue"
import { DateTime } from "luxon"
import { isNil, isNull, isUndefined } from "lodash"
import currentUserApi, { UserRoles, type UserAsShow } from "@/api/current-user-api"
import { PreferenceKeys, PreferenceValueMap } from "@/api/users/preferences-api"
export { UserRoles, type UserAsShow }
@@ -35,6 +37,18 @@ export function useCurrentUser<IsLoaded extends boolean = false>() {
return state.currentUser?.roles.includes(UserRoles.SYSTEM_ADMIN)
})
function getPreference<K extends PreferenceKeys>(key: K): PreferenceValueMap[K] | null {
if (isNull(state.currentUser)) return null
const { preferences } = state.currentUser
if (isUndefined(preferences)) return null
const preference = preferences.find((p) => p.key === key)
if (isNil(preference)) return null
return preference.value as PreferenceValueMap[K]
}
async function fetch(): Promise<UserAsShow> {
state.isLoading = true
try {
@@ -68,6 +82,7 @@ export function useCurrentUser<IsLoaded extends boolean = false>() {
reset,
// helpers
isSystemAdmin,
getPreference,
}
}