fix first online resevation

This commit is contained in:
root
2026-05-09 20:01:51 -04:00
parent c4a45c8b21
commit 09b0e3b55f
75 changed files with 6394 additions and 2190 deletions
+6 -12
View File
@@ -3,25 +3,19 @@ const API_BASE =
?? process.env.NEXT_PUBLIC_API_URL
?? 'http://localhost:4000/api/v1'
async function getClerkToken(): Promise<string | null> {
export const EMPLOYEE_TOKEN_KEY = 'employee_token'
async function getAuthToken(): Promise<string | null> {
if (typeof window === 'undefined') return null
try {
// In Next.js App Router, the Clerk session token is available via the Clerk SDK
// For client-side calls, we read it from a cookie set by @clerk/nextjs
if (typeof window !== 'undefined') {
// Client-side: use window.__clerk if available
const clerk = (window as any).__clerk
if (clerk?.session) {
return await clerk.session.getToken()
}
}
return null
return localStorage.getItem(EMPLOYEE_TOKEN_KEY)
} catch {
return null
}
}
export async function apiFetch<T>(path: string, options?: RequestInit): Promise<T> {
const token = await getClerkToken()
const token = await getAuthToken()
const isFormData = typeof FormData !== 'undefined' && options?.body instanceof FormData
const headers: Record<string, string> = {