• Mahmoud Aglan's avatar
    feat: branding persists in Supabase — survives deploys · 03a75d37
    Mahmoud Aglan authored
    PROBLEM: Theme was stored in local theme.json inside Docker container.
    Every deploy rebuilt container → all branding settings LOST.
    
    FIX: Dual storage — writes to both local file AND Supabase.
    Player app reads from Supabase API (persistent).
    
    Changes:
    1. New API: /api/branding.php
       - GET: returns full theme from platform_theme + platform_assets tables
       - POST save_theme: upserts values into platform_theme
       - POST save_asset: upserts asset URLs into platform_assets
       - Public endpoint (cached 60s)
    
    2. theme.js updated:
       - Fetches from /api/branding.php instead of local theme.json
       - Same apply logic (CSS vars, animations, button shapes)
    
    3. admin/branding.php updated:
       - Reads from Supabase on page load (not just local file)
       - Saves to BOTH local file AND Supabase on every edit
       - Auto-save JS still works (posts to same page → writes to Supabase)
    
    Flow:
    - Admin edits color → auto-save → PHP writes to Supabase + local
    - Player opens app → theme.js fetches /api/branding.php → Supabase query
    - Deploy happens → local file reset → Supabase still has all values 
    - Admin page reloads → reads from Supabase → shows saved values Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    03a75d37
branding.php 3.61 KB