mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
Redesign AdminSettings with tabs navigation and favorites
- Add tab-based navigation (Favorites, Branding, Theme, Payments, etc.) - Create useFavoriteSettings hook for localStorage-based favorites - Create SettingCard component for consistent setting display - Add global search functionality - Implement collapsible sections for theme presets and colors - Group settings by meta-categories (payments, subscriptions, etc.) - Add dropdown for additional categories (More menu) - Modern UI with improved spacing and interactions
This commit is contained in:
49
src/hooks/useFavoriteSettings.ts
Normal file
49
src/hooks/useFavoriteSettings.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
|
||||
const STORAGE_KEY = 'admin_favorite_settings'
|
||||
|
||||
export function useFavoriteSettings() {
|
||||
const [favorites, setFavorites] = useState<string[]>(() => {
|
||||
try {
|
||||
const stored = localStorage.getItem(STORAGE_KEY)
|
||||
return stored ? JSON.parse(stored) : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
})
|
||||
|
||||
// Sync to localStorage
|
||||
useEffect(() => {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(favorites))
|
||||
} catch {
|
||||
// Ignore storage errors
|
||||
}
|
||||
}, [favorites])
|
||||
|
||||
const toggleFavorite = useCallback((settingKey: string) => {
|
||||
setFavorites(prev => {
|
||||
if (prev.includes(settingKey)) {
|
||||
return prev.filter(key => key !== settingKey)
|
||||
} else {
|
||||
return [...prev, settingKey]
|
||||
}
|
||||
})
|
||||
}, [])
|
||||
|
||||
const isFavorite = useCallback((settingKey: string) => {
|
||||
return favorites.includes(settingKey)
|
||||
}, [favorites])
|
||||
|
||||
const clearFavorites = useCallback(() => {
|
||||
setFavorites([])
|
||||
}, [])
|
||||
|
||||
return {
|
||||
favorites,
|
||||
toggleFavorite,
|
||||
isFavorite,
|
||||
clearFavorites,
|
||||
count: favorites.length
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user