Added ProfileSelection when no profile is selected

This commit is contained in:
2024-04-16 11:34:13 +02:00
parent c1108314c1
commit 1269d3b838
2 changed files with 46 additions and 14 deletions

View File

@@ -149,6 +149,7 @@ export const useDataStore = defineStore('data', () => {
const loaded = ref(false)
const showProfileSelection = ref(false)
const ownTenant = ref({
calendarConfig: {
eventTypes: []
@@ -271,11 +272,19 @@ export const useDataStore = defineStore('data', () => {
let profileconnections = (await supabase.from("profileconnections").select()).data
let profiles = (await supabase.from("profiles").select()).data
let profileId = profileconnections.find(i => i.active).profile_id
activeProfile.value = profiles.find(i => i.id === profileId)
currentTenant.value = activeProfile.value.tenant
let activeProfileConnection = profileconnections.find(i => i.active)
if(activeProfileConnection) {
activeProfile.value = profiles.find(i => i.id === activeProfileConnection.profile_id)
currentTenant.value = activeProfile.value.tenant
await fetchData()
} else {
console.log("No Profile Active")
await fetchOwnProfiles()
await fetchTenants()
showProfileSelection.value = true
}
await fetchData()
}
@@ -284,24 +293,22 @@ export const useDataStore = defineStore('data', () => {
let profileconnections = (await supabase.from("profileconnections").select()).data
let oldActiveProfileId = profileconnections.find(i => i.active).profile_id
let oldActiveProfileConnection = profileconnections.find(i => i.active)
const {error} = await supabase.from("profileconnections").update({active: true}).eq("profile_id", newActiveProfileId)
if(error) {
console.log(error)
} else {
const {error} = await supabase.from("profileconnections").update({active: false}).eq("profile_id", oldActiveProfileId)
if(error) {
} else {
reloadNuxtApp({
path:"/",
ttl: 10000
})
if(oldActiveProfileConnection){
const {error} = await supabase.from("profileconnections").update({active: false}).eq("profile_id", oldActiveProfileConnection.profile_id)
}
reloadNuxtApp({
path:"/",
ttl: 10000
})
/*await clearStore()
await fetchData()
router.push("/")
@@ -1479,6 +1486,7 @@ export const useDataStore = defineStore('data', () => {
//General
currentTenant,
loaded,
showProfileSelection,
ownTenant,
initializeData,
changeProfile,