use zustand

This commit is contained in:
john 2025-08-10 16:16:23 +02:00
parent d2d358bff2
commit 5f29bc436c
15 changed files with 74 additions and 83 deletions

View file

@ -1,6 +1,8 @@
import { paths } from './schema.ts'
import createClient, { Middleware } from 'openapi-fetch'
import { dispatchMessage } from '../messageBus/messageBus.ts'
import { useUserStore } from '../user/user.ts'
import { getUserFromCookie } from '../auth/getUserFromCookie.ts'
export const initClient = () => {
const client = createClient<paths>({ baseUrl: import.meta.env.VITE_API_URL })
@ -9,6 +11,10 @@ export const initClient = () => {
if (response.status === 401) {
dispatchMessage('auth:unauthorized', null)
}
const user = getUserFromCookie()
console.debug('got user cookie', user)
useUserStore.getState().setUser(user)
},
}