fix: Single source nav + dark logo support + customer settings debug

##  Issue 1: Single Source of Truth for Navigation
**Problem:** Confusing dual nav sources (PHP + TypeScript fallback)
**Solution:** Removed static TypeScript fallback tree
**Result:** PHP NavigationRegistry is now the ONLY source
- More flexible (can check WooCommerce settings, extend via addons)
- Easier to maintain
- Clear error if backend data missing

##  Issue 2: Logo in All Modes
**Already Working:** Header component renders in all modes
- Standalone 
- WP-Admin normal 
- WP-Admin fullscreen 

##  Issue 5: Customer Settings 404 Debug
**Added:** Debug logging to track endpoint calls
**Note:** Routes are correctly registered
- May need WordPress permalinks flush
- Check debug.log for errors

##  Issue 6: Dark Mode Logo Support
**Implemented:**
1. **Backend:**
   - Added `store_logo_dark` to branding endpoint
   - Returns both light and dark logos

2. **Header Component:**
   - Detects dark mode via MutationObserver
   - Switches logo based on theme
   - Falls back to light logo if dark not set

3. **Login Screen:**
   - Same dark mode detection
   - Theme-aware logo display
   - Seamless theme switching

4. **SVG Support:**
   - Already supported via `accept="image/*"`
   - Works for all image formats

**Result:** Perfect dark/light logo switching everywhere! 🌓

---

## Files Modified:
- `nav/tree.ts` - Removed static fallback
- `App.tsx` - Dark logo in header
- `Login.tsx` - Dark logo in login
- `StoreController.php` - Dark logo in branding endpoint + debug logs
- `Store.tsx` - Already has dark logo upload field
- `StoreSettingsProvider.php` - Already has dark logo backend

## Testing:
1. Upload dark logo in Store settings
2. Switch theme - logo should change
3. Check customer-settings endpoint in browser console
4. Verify nav items from PHP only
This commit is contained in:
dwindown
2025-11-11 10:12:30 +07:00
parent 9c5bdebf6f
commit 432d84992c
4 changed files with 64 additions and 100 deletions

View File

@@ -12,13 +12,31 @@ export function Login() {
const [password, setPassword] = useState('');
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState('');
const [branding, setBranding] = useState<{ logo: string; tagline: string; storeName: string }>({
const [branding, setBranding] = React.useState({
logo: '',
tagline: '',
storeName: 'WooNooW'
logoDark: '',
storeName: 'WooNooW',
});
const [isDark, setIsDark] = React.useState(false);
const navigate = useNavigate();
// Detect dark mode
React.useEffect(() => {
const checkDarkMode = () => {
setIsDark(document.documentElement.classList.contains('dark'));
};
checkDarkMode();
const observer = new MutationObserver(checkDarkMode);
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class']
});
return () => observer.disconnect();
}, []);
// Fetch branding (public endpoint - no auth required)
useEffect(() => {
fetch((window.WNW_CONFIG?.restUrl || '') + '/store/branding')
@@ -26,8 +44,8 @@ export function Login() {
.then(data => {
setBranding({
logo: data.store_logo || '',
tagline: data.store_tagline || '',
storeName: data.store_name || 'WooNooW'
logoDark: data.store_logo_dark || '',
storeName: data.store_name || 'WooNooW',
});
})
.catch(err => console.error('Failed to load branding:', err));
@@ -71,9 +89,9 @@ export function Login() {
<div className="bg-white dark:bg-gray-900/50 dark:backdrop-blur-xl dark:border dark:border-gray-800 rounded-lg shadow-xl p-8">
{/* Logo */}
<div className="text-center mb-8">
{branding.logo ? (
{(isDark && branding.logoDark) || branding.logo ? (
<img
src={branding.logo}
src={(isDark && branding.logoDark) || branding.logo}
alt={branding.storeName}
className="h-16 mx-auto mb-3 object-contain"
/>