init commit,

This commit is contained in:
louiscklaw
2025-05-28 09:55:51 +08:00
commit efe70ceb69
8042 changed files with 951668 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { Session } from '@supabase/supabase-js';
import React, { createContext, useContext, useState } from 'react';
import { supabase } from '../supabaseClient';
export const SessionContext = createContext<{
session: Session | null;
} | null>(null);
export const SessionProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [session] = useState(() => supabase.auth.session());
// const value = useMemo(() => ({ session, setSession }), [session, setSession]);
const value = { session };
return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>;
};
export const useSession = () => {
const context = useContext(SessionContext);
if (!context) {
throw new Error('useSession must be used within a SessionProvider');
}
return context;
};