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:
dwindown
2025-12-24 12:31:48 +07:00
parent 3af2787d03
commit 7a8f9cb9a9
3 changed files with 250 additions and 8 deletions

View File

@@ -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;
}
};