feat(admin): archive users and their profiles permanently
This commit is contained in:
@@ -19,6 +19,7 @@ export const useProfileStore = defineStore("profile", () => {
|
||||
})
|
||||
|
||||
const profiles = ref([])
|
||||
const allProfiles = ref([])
|
||||
const ownProfiles = ref([])
|
||||
const activeProfile = ref(null)
|
||||
const tenants = ref([])
|
||||
@@ -60,8 +61,8 @@ export const useProfileStore = defineStore("profile", () => {
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
await fetchOwnProfiles()
|
||||
await fetchProfiles()
|
||||
await fetchOwnProfiles()
|
||||
await fetchTenants()
|
||||
await fetchOwnTenant()
|
||||
loaded.value = true
|
||||
@@ -71,6 +72,7 @@ export const useProfileStore = defineStore("profile", () => {
|
||||
loaded.value = false
|
||||
ownTenant.value = {}
|
||||
profiles.value = []
|
||||
allProfiles.value = []
|
||||
ownProfiles.value = []
|
||||
tenants.value = []
|
||||
}
|
||||
@@ -92,10 +94,13 @@ export const useProfileStore = defineStore("profile", () => {
|
||||
|
||||
async function fetchProfiles() {
|
||||
try {
|
||||
const res = await useNuxtApp().$api("/api/tenant/profiles")
|
||||
profiles.value = res?.data || []
|
||||
const res = await useNuxtApp().$api("/api/tenant/profiles", { query: { includeArchived: true } })
|
||||
// Retain historical names while keeping archived profiles out of selections.
|
||||
allProfiles.value = res?.data || []
|
||||
profiles.value = allProfiles.value.filter(profile => profile.active && !profile.archived_at)
|
||||
} catch (e) {
|
||||
profiles.value = activeProfile.value ? [activeProfile.value] : []
|
||||
allProfiles.value = profiles.value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +117,8 @@ export const useProfileStore = defineStore("profile", () => {
|
||||
})
|
||||
|
||||
const getProfileById = computed(() => (itemId) => {
|
||||
return profiles.value.find((item) => item.id === itemId || item.user_id === itemId)
|
||||
const profile = allProfiles.value.find((item) => item.id === itemId || item.user_id === itemId)
|
||||
return profile ? { ...profile, fullName: profile.full_name || profile.fullName } : { fullName: "Unbekanntes Profil" }
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user