feat: basic initial UI layout for mobile and desktop

This commit is contained in:
Jose Selesan
2026-09-07 09:33:07 -03:00
parent 0aa5d70101
commit b41fffa40a
46 changed files with 2102 additions and 125 deletions

View File

@@ -0,0 +1,36 @@
import { createContext, useContext, useEffect, useState, type ReactNode } from 'react'
import { authClient } from '../lib/auth-client'
type AuthSession = {
user: (typeof authClient.$Infer.Session)['user']
session: (typeof authClient.$Infer.Session)['session']
}
type AuthContextValue = {
user: AuthSession['user'] | null
session: AuthSession['session'] | null
isPending: boolean
refresh: () => Promise<void>
}
const AuthContext = createContext<AuthContextValue | null>(null)
export function AuthProvider({ children }: { children: ReactNode }) {
const { data, isPending } = authClient.useSession()
const refresh = async () => {
await authClient.getSession()
}
return (
<AuthContext.Provider value={{ user: data?.user ?? null, session: data?.session ?? null, isPending, refresh }}>
{children}
</AuthContext.Provider>
)
}
export function useAuth() {
const ctx = useContext(AuthContext)
if (!ctx) throw new Error('useAuth debe usarse dentro de <AuthProvider>')
return ctx
}