Save current app progress

This commit is contained in:
2026-05-28 22:55:43 +01:00
parent 134789cee1
commit d85e327c07
5 changed files with 481 additions and 414 deletions

View File

@@ -6,9 +6,7 @@ interface AuthContextType {
user: User | null;
session: Session | null;
loading: boolean;
isDemoMode: boolean;
isSpotifyAuthenticated: boolean;
enableDemoMode: () => void;
enableSpotifyMode: () => void;
}
@@ -16,9 +14,7 @@ const AuthContext = createContext<AuthContextType>({
user: null,
session: null,
loading: true,
isDemoMode: false,
isSpotifyAuthenticated: false,
enableDemoMode: () => {},
enableSpotifyMode: () => {},
});
@@ -28,18 +24,9 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
const [user, setUser] = useState<User | null>(null);
const [session, setSession] = useState<Session | null>(null);
const [loading, setLoading] = useState(true);
const [isDemoMode, setIsDemoMode] = useState(false);
const [isSpotifyAuthenticated, setIsSpotifyAuthenticated] = useState(false);
const enableDemoMode = () => {
setIsDemoMode(true);
setIsSpotifyAuthenticated(false);
setUser({ id: '00000000-0000-4000-8000-000000000002', email: 'demo@roadtripdj.com' } as User);
setLoading(false);
};
const enableSpotifyMode = () => {
setIsDemoMode(false);
setIsSpotifyAuthenticated(true);
setLoading(false);
};
@@ -49,12 +36,10 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
setSession(session);
setUser(session?.user ?? null);
if (!session) {
setIsDemoMode(false);
setIsSpotifyAuthenticated(false);
} else {
const isSpotify = !!session.user?.user_metadata?.spotify_id;
setIsSpotifyAuthenticated(isSpotify);
setIsDemoMode(false);
}
setLoading(false);
});
@@ -63,12 +48,10 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
setSession(session);
setUser(session?.user ?? null);
if (!session) {
setIsDemoMode(false);
setIsSpotifyAuthenticated(false);
} else {
const isSpotify = !!session.user?.user_metadata?.spotify_id;
setIsSpotifyAuthenticated(isSpotify);
setIsDemoMode(false);
}
setLoading(false);
});
@@ -77,7 +60,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
}, []);
return (
<AuthContext.Provider value={{ user, session, loading, isDemoMode, isSpotifyAuthenticated, enableDemoMode, enableSpotifyMode }}>
<AuthContext.Provider value={{ user, session, loading, isSpotifyAuthenticated, enableSpotifyMode }}>
{children}
</AuthContext.Provider>
);