feat: remove unused texture files and add model metadata
- Deleted various texture files related to the Raspberry Pi camera model. - Introduced a new JSON file to store model metadata including IDs, names, and URLs. - Implemented authentication and session management using Supabase. - Created a header component for navigation and user session display. - Added protected routes to restrict access to certain pages. - Developed a private layout for authenticated users. - Enhanced the home page to dynamically load models from the new JSON file. - Updated the login page to handle user authentication. - Created a model uploader for users to upload 3D models. - Improved overall styling and layout for better user experience.
This commit is contained in:
40
src/lib/AuthProvider.tsx
Normal file
40
src/lib/AuthProvider.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { createContext, useContext, useEffect, useState } from "react";
|
||||
import { supabase } from "./supabase";
|
||||
import { Session } from "@supabase/supabase-js";
|
||||
|
||||
type AuthContextType = {
|
||||
session: Session | null;
|
||||
loading: boolean;
|
||||
};
|
||||
|
||||
const AuthContext = createContext<AuthContextType>({ session: null, loading: true });
|
||||
|
||||
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
const [session, setSession] = useState<Session | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
supabase.auth.getSession().then(({ data: { session } }) => {
|
||||
setSession(session);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
const { data: listener } = supabase.auth.onAuthStateChange((_event, session) => {
|
||||
setSession(session);
|
||||
});
|
||||
|
||||
return () => {
|
||||
listener.subscription.unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={{ session, loading }}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useAuth() {
|
||||
return useContext(AuthContext);
|
||||
}
|
||||
6
src/lib/supabase.ts
Normal file
6
src/lib/supabase.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
|
||||
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL!;
|
||||
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY!;
|
||||
|
||||
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
|
||||
Reference in New Issue
Block a user