feat(app): auth, orgs/events UI, router guards, and dev tooling

- Add Sanctum auth flow (store, composables, login, axios interceptors)
- Add dashboard, organisation list/detail, events CRUD dialogs
- Wire router guards, navigation, organisation switcher in layout
- Replace Vuexy @db types in NavSearchBar; add @iconify/types; themeConfig title typing
- Vuetify settings.scss + resolve configFile via fileURLToPath; drop dead path aliases
- Root index redirects to dashboard; fix events table route name
- API: DevSeeder + DatabaseSeeder updates; docs TEST_SCENARIO; corporate identity assets

Made-with: Cursor
This commit is contained in:
2026-04-07 21:51:10 +02:00
parent 0d24506c89
commit c417a6647a
45 changed files with 11554 additions and 832 deletions

View File

@@ -0,0 +1,81 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import { useOrganisationStore } from '@/stores/useOrganisationStore'
import type { MeResponse, Organisation, User } from '@/types/auth'
const TOKEN_KEY = 'crewli_token'
export const useAuthStore = defineStore('auth', () => {
const token = ref<string | null>(localStorage.getItem(TOKEN_KEY))
const user = ref<User | null>(null)
const organisations = ref<Organisation[]>([])
const appRoles = ref<string[]>([])
const permissions = ref<string[]>([])
const isAuthenticated = computed(() => !!token.value)
const isSuperAdmin = computed(() => appRoles.value?.includes('super_admin') ?? false)
const currentOrganisation = computed(() => {
const orgStore = useOrganisationStore()
return organisations.value.find(o => o.id === orgStore.activeOrganisationId)
?? organisations.value[0]
?? null
})
function setToken(newToken: string) {
token.value = newToken
localStorage.setItem(TOKEN_KEY, newToken)
}
function setUser(me: MeResponse) {
user.value = {
id: me.id,
name: me.name,
email: me.email,
timezone: me.timezone,
locale: me.locale,
avatar: me.avatar,
}
organisations.value = me.organisations
appRoles.value = me.app_roles
permissions.value = me.permissions
// Auto-select first organisation if none is active
const orgStore = useOrganisationStore()
if (!orgStore.activeOrganisationId && me.organisations.length > 0) {
orgStore.setActiveOrganisation(me.organisations[0].id)
}
}
function setActiveOrganisation(id: string) {
const orgStore = useOrganisationStore()
orgStore.setActiveOrganisation(id)
}
function logout() {
token.value = null
user.value = null
organisations.value = []
appRoles.value = []
permissions.value = []
localStorage.removeItem(TOKEN_KEY)
const orgStore = useOrganisationStore()
orgStore.clear()
}
return {
token,
user,
organisations,
appRoles,
permissions,
isAuthenticated,
isSuperAdmin,
currentOrganisation,
setToken,
setUser,
setActiveOrganisation,
logout,
}
})