From 385536e3adb38e71ed1a480f0dc30b9d9152229b Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 27 Sep 2025 20:58:59 +0000 Subject: [PATCH] Prettier format pending files --- client/contexts/AuthContext.tsx | 16 ++- client/lib/supabase.ts | 63 +++++++--- client/pages/Dashboard.tsx | 215 ++++++++++++++++++-------------- client/pages/Onboarding.tsx | 9 +- 4 files changed, 180 insertions(+), 123 deletions(-) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index e1800bf7..d0dd37ee 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -3,7 +3,10 @@ import { User, Session } from "@supabase/supabase-js"; import { supabase } from "@/lib/supabase"; import { UserProfile } from "@/lib/database.types"; import { aethexToast } from "@/lib/aethex-toast"; -import { aethexUserService, type AethexUserProfile } from "@/lib/aethex-database-adapter"; +import { + aethexUserService, + type AethexUserProfile, +} from "@/lib/aethex-database-adapter"; interface AuthContextType { user: User | null; @@ -123,8 +126,12 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ console.error("SignIn error details:", error); let errorMessage = error.message; - if (error.message?.includes("Failed to fetch") || error.name === "AuthRetryableFetchError") { - errorMessage = "Unable to connect to authentication service. Please check your internet connection and try again."; + if ( + error.message?.includes("Failed to fetch") || + error.name === "AuthRetryableFetchError" + ) { + errorMessage = + "Unable to connect to authentication service. Please check your internet connection and try again."; } aethexToast.error({ @@ -151,7 +158,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ if (data.user) { aethexToast.success({ title: "Account created!", - description: "Please check your email to verify your account, then sign in.", + description: + "Please check your email to verify your account, then sign in.", }); } } catch (error: any) { diff --git a/client/lib/supabase.ts b/client/lib/supabase.ts index 150b0248..6589c6fe 100644 --- a/client/lib/supabase.ts +++ b/client/lib/supabase.ts @@ -13,7 +13,7 @@ console.log("Supabase Config:", { hasKey: !!supabaseAnonKey, url: supabaseUrl, keyPrefix: supabaseAnonKey?.substring(0, 20) + "...", - isSupabaseConfigured + isSupabaseConfigured, }); let supabaseClient: any = null; @@ -31,12 +31,18 @@ if (isSupabaseConfigured) { setTimeout(async () => { try { console.log("🔍 Testing Supabase connection to:", supabaseUrl); - const { data, error } = await supabaseClient.from('user_profiles').select('count', { count: 'exact', head: true }); + const { data, error } = await supabaseClient + .from("user_profiles") + .select("count", { count: "exact", head: true }); if (error) { console.warn("⚠️ Supabase connection test failed:", error.message); console.log("🔄 Falling back to mock authentication for development"); } else { - console.log("✅ Supabase connection successful - found", data, "user profiles"); + console.log( + "✅ Supabase connection successful - found", + data, + "user profiles", + ); } } catch (err: any) { console.warn("⚠️ Supabase connection error:", err.message); @@ -61,7 +67,7 @@ if (isSupabaseConfigured) { // Create a proxy that falls back to mock when Supabase fails export const supabase = new Proxy(supabaseClient || {}, { get(target, prop) { - if (prop === 'auth') { + if (prop === "auth") { return { signInWithPassword: async (credentials: any) => { if (isSupabaseConfigured && target && target.auth) { @@ -72,17 +78,27 @@ export const supabase = new Proxy(supabaseClient || {}, { return result; } catch (error: any) { console.warn("⚠️ Supabase authentication failed:", error.message); - if (error.message?.includes('Failed to fetch') || - error.name === 'AuthRetryableFetchError' || - error.message?.includes('fetch')) { + if ( + error.message?.includes("Failed to fetch") || + error.name === "AuthRetryableFetchError" || + error.message?.includes("fetch") + ) { console.log("🔄 Falling back to mock authentication"); - return await mockAuth.signInWithPassword(credentials.email, credentials.password); + return await mockAuth.signInWithPassword( + credentials.email, + credentials.password, + ); } throw error; } } else { - console.log("🔄 Using mock authentication (Supabase not configured)"); - return await mockAuth.signInWithPassword(credentials.email, credentials.password); + console.log( + "🔄 Using mock authentication (Supabase not configured)", + ); + return await mockAuth.signInWithPassword( + credentials.email, + credentials.password, + ); } }, signOut: async () => { @@ -124,12 +140,12 @@ export const supabase = new Proxy(supabaseClient || {}, { } } return mockAuth.onAuthStateChange(callback); - } + }, }; } - if (prop === 'from') { - if (isSupabaseConfigured && target && typeof target.from === 'function') { + if (prop === "from") { + if (isSupabaseConfigured && target && typeof target.from === "function") { return target.from.bind(target); } @@ -147,16 +163,20 @@ export const supabase = new Proxy(supabaseClient || {}, { single: async () => ({ data: rows[0] ?? {}, error: null }), then: (resolve: any) => resolve({ data: rows, error: null }), catch: () => builder, - finally: (cb: any) => { cb?.(); return builder; }, + finally: (cb: any) => { + cb?.(); + return builder; + }, }; return builder; }; const createMockTable = (table: string) => ({ select: (_cols?: any, _opts?: any) => createMockBuilder([]), - insert: (payload?: any) => createMockBuilder( - Array.isArray(payload) ? payload : payload ? [payload] : [], - ), + insert: (payload?: any) => + createMockBuilder( + Array.isArray(payload) ? payload : payload ? [payload] : [], + ), update: (payload?: any) => createMockBuilder(payload || {}), delete: () => createMockBuilder([]), }); @@ -165,7 +185,7 @@ export const supabase = new Proxy(supabaseClient || {}, { } return target[prop]; - } + }, }); // Auth helpers @@ -189,7 +209,7 @@ export const channel = supabase.channel; try { const testLogin = await supabase.auth.signInWithPassword({ email: "test@example.com", - password: "test123" + password: "test123", }); console.log("Auth test result:", testLogin); } catch (error) { @@ -197,7 +217,10 @@ export const channel = supabase.channel; } try { - const { data, error } = await supabase.from('user_profiles').select('*').limit(1); + const { data, error } = await supabase + .from("user_profiles") + .select("*") + .limit(1); console.log("Database test - data:", data, "error:", error); } catch (dbError) { console.error("Database test error:", dbError); diff --git a/client/pages/Dashboard.tsx b/client/pages/Dashboard.tsx index d0a2d768..ce7481b2 100644 --- a/client/pages/Dashboard.tsx +++ b/client/pages/Dashboard.tsx @@ -55,7 +55,11 @@ export default function Dashboard() { }); useEffect(() => { - console.log("Dashboard useEffect:", { user: !!user, profile: !!profile, authLoading }); + console.log("Dashboard useEffect:", { + user: !!user, + profile: !!profile, + authLoading, + }); // Only redirect to login when auth is resolved and there's no user if (!user && !authLoading) { @@ -97,7 +101,9 @@ export default function Dashboard() { // Load user's achievements with error handling let userAchievements = []; try { - userAchievements = await aethexAchievementService.getUserAchievements(user!.id); + userAchievements = await aethexAchievementService.getUserAchievements( + user!.id, + ); setAchievements(userAchievements); } catch (achievementError) { console.warn("Could not load achievements:", achievementError); @@ -283,8 +289,12 @@ export default function Dashboard() {
-

Complete Your Profile

-

Set up your profile to unlock all features

+

+ Complete Your Profile +

+

+ Set up your profile to unlock all features +

@@ -315,10 +325,12 @@ export default function Dashboard() {

- Welcome back, {profile?.full_name || user.email?.split('@')[0]} + Welcome back,{" "} + {profile?.full_name || user.email?.split("@")[0]}

- {profile?.role || 'Member'} • Level {profile?.level || 1} • 7 day streak 🔥 + {profile?.role || "Member"} • Level {profile?.level || 1} • 7 + day streak 🔥

@@ -343,7 +355,10 @@ export default function Dashboard() {
User Avatar @@ -351,10 +366,10 @@ export default function Dashboard() {

- {profile?.full_name || user.email?.split('@')[0]} + {profile?.full_name || user.email?.split("@")[0]}

- {profile?.role || 'Member'} + {profile?.role || "Member"}

XP Progress - {profile?.total_xp || 0} / {((profile?.level || 1) * 1000)} + {profile?.total_xp || 0} /{" "} + {(profile?.level || 1) * 1000}
@@ -481,58 +497,60 @@ export default function Dashboard() {
) : ( projects.slice(0, 3).map((project: any, index) => ( -
-
-
- -
-
-

{project.title}

-

- {project.status?.replace("_", " ").toUpperCase()} •{" "} - {project.technologies?.slice(0, 2).join(", ") || - "No tech specified"} -

-
-
-
-
-

- {getProgressPercentage(project)}% -

-
-
+
+
+
+ +
+
+

{project.title}

+

+ {project.status?.replace("_", " ").toUpperCase()}{" "} + •{" "} + {project.technologies?.slice(0, 2).join(", ") || + "No tech specified"} +

- - {getPriorityFromTech(project.technologies || [])} - - +
+
+

+ {getProgressPercentage(project)}% +

+
+
+
+
+ + {getPriorityFromTech(project.technologies || [])} + + +
-
)) )} @@ -551,49 +569,54 @@ export default function Dashboard() { {achievements.length === 0 ? (
-

No achievements unlocked yet. Complete projects to earn achievements!

+

+ No achievements unlocked yet. Complete projects to + earn achievements! +

) : ( achievements.map((achievement: any, index) => { - const Icon = getAchievementIcon(achievement.icon || 'star'); - return ( -
-
-
- -
-
-

+
+
- {achievement.title} -

-

- {achievement.description} -

+ +
+
+

+ {achievement.title} +

+

+ {achievement.description} +

+
+ {achievement.earned && ( + + )}
- {achievement.earned && ( - - )}
-
- ); + ); }) )}
diff --git a/client/pages/Onboarding.tsx b/client/pages/Onboarding.tsx index 782a48b8..1c34f52e 100644 --- a/client/pages/Onboarding.tsx +++ b/client/pages/Onboarding.tsx @@ -123,8 +123,10 @@ export default function Onboarding() { const existing = await aethexUserService.getCurrentUser(); const payload = { username: `${data.personalInfo.firstName || user.email?.split("@")[0] || "user"}`, - full_name: `${data.personalInfo.firstName} ${data.personalInfo.lastName}`.trim(), - user_type: (userTypeMap[data.userType || "member"] as any) || "community_member", + full_name: + `${data.personalInfo.firstName} ${data.personalInfo.lastName}`.trim(), + user_type: + (userTypeMap[data.userType || "member"] as any) || "community_member", experience_level: (data.experience.level as any) || "beginner", bio: data.experience.previousProjects || undefined, } as any; @@ -157,7 +159,8 @@ export default function Onboarding() { function formatError(err: any) { if (!err) return "Unknown error"; if (typeof err === "string") return err; - if (err instanceof Error) return err.message + (err.stack ? `\n${err.stack}` : ""); + if (err instanceof Error) + return err.message + (err.stack ? `\n${err.stack}` : ""); if ((err as any).message) return (err as any).message; try { return JSON.stringify(err);