refactor: implement role-based profile dashboard with custom tab navigation and barber-specific views
This commit is contained in:
@@ -69,19 +69,24 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
storage.get<{ favorites?: string[]; cart?: CartItem[] }>('smart-agenda-mobile-state', {}).then((stored) => {
|
||||
if (!mounted) return;
|
||||
if (Array.isArray(stored.favorites)) setFavorites(stored.favorites);
|
||||
if (Array.isArray(stored.cart)) setCart(stored.cart);
|
||||
});
|
||||
if (user?.id) {
|
||||
storage.get<{ favorites?: string[]; cart?: CartItem[] }>(`smart-agenda-user-${user.id}`, {}).then((stored) => {
|
||||
if (!mounted) return;
|
||||
setFavorites(Array.isArray(stored.favorites) ? stored.favorites : []);
|
||||
});
|
||||
} else {
|
||||
setFavorites([]);
|
||||
}
|
||||
return () => {
|
||||
mounted = false;
|
||||
};
|
||||
}, []);
|
||||
}, [user?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
storage.set('smart-agenda-mobile-state', { favorites, cart });
|
||||
}, [favorites, cart]);
|
||||
if (user?.id) {
|
||||
storage.set(`smart-agenda-user-${user.id}`, { favorites, cart });
|
||||
}
|
||||
}, [favorites, cart, user?.id]);
|
||||
|
||||
const applySupabaseUser = async (authUser: any): Promise<User | undefined> => {
|
||||
if (!authUser) return undefined;
|
||||
|
||||
Reference in New Issue
Block a user