chore: update frontend configuration

This commit is contained in:
Matthieu
2025-09-26 11:29:47 +02:00
parent b7caa4f552
commit a78938a4d1
64 changed files with 5790 additions and 5129 deletions

View File

@@ -6,13 +6,13 @@ const buildUrl = (path) => {
return `${base}${path}`
}
export function useProfiles() {
export function useProfiles () {
const profiles = useState('profiles:list', () => [])
const loadingProfiles = useState('profiles:loading', () => false)
const profilesLoaded = useState('profiles:loaded', () => false)
const getSessionHeaders = () => {
if (!process.server) return undefined
if (!process.server) { return undefined }
const headers = useRequestHeaders(['cookie'])
return headers?.cookie ? { cookie: headers.cookie } : undefined
}
@@ -23,7 +23,7 @@ export function useProfiles() {
profiles.value = await $fetch(buildUrl('/profiles'), {
method: 'GET',
credentials: 'include',
headers: getSessionHeaders(),
headers: getSessionHeaders()
})
profilesLoaded.value = true
} catch (error) {
@@ -41,7 +41,7 @@ export function useProfiles() {
method: 'POST',
credentials: 'include',
body: { firstName, lastName },
headers: getSessionHeaders(),
headers: getSessionHeaders()
})
await fetchProfiles()
return profile
@@ -51,7 +51,7 @@ export function useProfiles() {
await $fetch(buildUrl(`/profiles/${profileId}`), {
method: 'DELETE',
credentials: 'include',
headers: getSessionHeaders(),
headers: getSessionHeaders()
})
await fetchProfiles()
}
@@ -62,6 +62,6 @@ export function useProfiles() {
profilesLoaded,
fetchProfiles,
createProfile,
deleteProfile,
deleteProfile
}
}