Fix logo/favicon upload, badge colors, and page title issues
Issue 1 - Logo/Favicon Upload: - Add preview before upload (user must confirm) - Show selected file preview with confirm/cancel buttons - Fallback to current image if preview cancelled - File size validation (2MB logo, 1MB favicon) - Add STORAGE_RLS_FIX.sql for storage policy setup Issue 2 - Badge Colors: - Already implemented correctly in all files - All "Lunas" badges use bg-brand-accent class - Verified: OrderDetail, MemberOrders, Dashboard, MemberDashboard Issue 3 - Page Title Error: - Change .single() to .maybeSingle() in useBranding hook - Handle error case gracefully with default branding - Set default title even when platform_settings is empty - This fixes the "JSON object requested, multiple (or no) rows returned" error 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,16 +50,23 @@ export function BrandingProvider({ children }: { children: ReactNode }) {
|
||||
const { data, error } = await supabase
|
||||
.from('platform_settings')
|
||||
.select('*')
|
||||
.single();
|
||||
.maybeSingle();
|
||||
|
||||
if (error) {
|
||||
console.error('Error fetching branding settings:', error);
|
||||
// Keep default branding on error - still set title
|
||||
document.title = defaultBranding.brand_name;
|
||||
return;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
let features = defaultBranding.homepage_features;
|
||||
|
||||
|
||||
// Parse homepage_features if it's a string
|
||||
if (data.homepage_features) {
|
||||
try {
|
||||
features = typeof data.homepage_features === 'string'
|
||||
? JSON.parse(data.homepage_features)
|
||||
features = typeof data.homepage_features === 'string'
|
||||
? JSON.parse(data.homepage_features)
|
||||
: data.homepage_features;
|
||||
} catch (e) {
|
||||
console.error('Error parsing homepage_features:', e);
|
||||
@@ -94,6 +101,9 @@ export function BrandingProvider({ children }: { children: ReactNode }) {
|
||||
if (data.brand_name) {
|
||||
document.title = data.brand_name;
|
||||
}
|
||||
} else {
|
||||
// No data found - use defaults and set title
|
||||
document.title = defaultBranding.brand_name;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user