Remove demo mode logic and use only Supabase

cgen-2e5fc2fd5a83443ca868ecd843fcca82
This commit is contained in:
Builder.io 2025-08-06 02:12:05 +00:00
parent 8b06e9cc71
commit d5f7b5c171

View file

@ -1,9 +1,8 @@
import React, { createContext, useContext, useEffect, useState } from "react"; import React, { createContext, useContext, useEffect, useState } from "react";
import { User, Session } from "@supabase/supabase-js"; import { User, Session } from "@supabase/supabase-js";
import { supabase, isSupabaseConfigured } from "@/lib/supabase"; import { supabase } from "@/lib/supabase";
import { UserProfile } from "@/lib/database.types"; import { UserProfile } from "@/lib/database.types";
import { aethexToast } from "@/lib/aethex-toast"; import { aethexToast } from "@/lib/aethex-toast";
import { DemoStorageService } from "@/lib/demo-storage";
import { import {
aethexUserService, aethexUserService,
aethexAchievementService, aethexAchievementService,
@ -45,15 +44,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
useEffect(() => { useEffect(() => {
// Check if Supabase is configured
if (!isSupabaseConfigured) {
console.warn(
"Supabase is not configured. Please set up your environment variables.",
);
setLoading(false);
return;
}
// Get initial session // Get initial session
supabase.auth supabase.auth
.getSession() .getSession()
@ -135,14 +125,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
const fetchUserProfile = async ( const fetchUserProfile = async (
userId: string, userId: string,
): Promise<AethexUserProfile | null> => { ): Promise<AethexUserProfile | null> => {
if (!isSupabaseConfigured) {
// Initialize demo data and get profile
DemoStorageService.initializeDemoData();
const demoProfile = DemoStorageService.getUserProfile();
setProfile(demoProfile as AethexUserProfile);
return demoProfile as AethexUserProfile;
}
try { try {
const userProfile = await aethexUserService.getCurrentUser(); const userProfile = await aethexUserService.getCurrentUser();
setProfile(userProfile); setProfile(userProfile);
@ -154,20 +136,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
}; };
const signIn = async (email: string, password: string) => { const signIn = async (email: string, password: string) => {
if (!isSupabaseConfigured) {
aethexToast.warning({
title: "Demo Mode",
description:
"Supabase not configured. This is a demo - please set up your Supabase project.",
});
// Simulate successful login for demo
setTimeout(() => {
setUser({ id: "demo-user", email } as User);
setSession({ user: { id: "demo-user", email } } as Session);
}, 500);
return;
}
try { try {
const { error } = await supabase.auth.signInWithPassword({ const { error } = await supabase.auth.signInWithPassword({
email, email,
@ -189,15 +157,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
password: string, password: string,
userData?: Partial<AethexUserProfile>, userData?: Partial<AethexUserProfile>,
) => { ) => {
if (!isSupabaseConfigured) {
aethexToast.warning({
title: "Demo Mode",
description:
"Supabase not configured. This is a demo - please set up your Supabase project.",
});
return;
}
try { try {
const { data, error } = await supabase.auth.signUp({ const { data, error } = await supabase.auth.signUp({
email, email,
@ -228,15 +187,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
}; };
const signInWithOAuth = async (provider: "github" | "google") => { const signInWithOAuth = async (provider: "github" | "google") => {
if (!isSupabaseConfigured) {
aethexToast.warning({
title: "Demo Mode",
description:
"OAuth login requires Supabase to be configured. Currently in demo mode.",
});
return;
}
try { try {
const { data, error } = await supabase.auth.signInWithOAuth({ const { data, error } = await supabase.auth.signInWithOAuth({
provider, provider,
@ -261,17 +211,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
}; };
const signOut = async () => { const signOut = async () => {
if (!isSupabaseConfigured) {
setUser(null);
setSession(null);
setProfile(null);
aethexToast.info({
title: "Signed out",
description: "Demo session ended",
});
return;
}
try { try {
const { error } = await supabase.auth.signOut(); const { error } = await supabase.auth.signOut();
if (error) throw error; if (error) throw error;
@ -287,19 +226,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
const updateProfile = async (updates: Partial<AethexUserProfile>) => { const updateProfile = async (updates: Partial<AethexUserProfile>) => {
if (!user) throw new Error("No user logged in"); if (!user) throw new Error("No user logged in");
if (!isSupabaseConfigured) {
// Use demo storage
const updatedProfile = DemoStorageService.updateUserProfile(
updates as any,
);
setProfile(updatedProfile as AethexUserProfile);
aethexToast.success({
title: "Profile updated",
description: "Your profile has been updated successfully",
});
return;
}
try { try {
const updatedProfile = await aethexUserService.updateProfile( const updatedProfile = await aethexUserService.updateProfile(
user.id, user.id,