Fallback listProfiles when table missing

cgen-f0da836d6f87442da49bcb67d2bb86f4
This commit is contained in:
Builder.io 2025-10-01 00:01:37 +00:00
parent 04667c4a8f
commit eec76c50d5

View file

@ -213,9 +213,22 @@ export const aethexUserService = {
if (error) {
if (isTableMissing(error)) {
throw new Error(
'Supabase table "user_profiles" is missing. Please run the required migrations.',
);
console.warn('user_profiles table missing during listProfiles - returning local demo profiles');
try {
const keys = Object.keys(localStorage || {}).filter((k) => k.startsWith('demo_profile_'));
const profiles = keys
.map((k) => {
try {
return JSON.parse(localStorage.getItem(k) || "null");
} catch {
return null;
}
})
.filter(Boolean) as AethexUserProfile[];
return profiles.slice(0, limit);
} catch {
return [];
}
}
throw error;
}