appcontext

This commit is contained in:
2026-03-10 17:07:16 +00:00
parent dd32b09127
commit 1ad78609e2
2 changed files with 21 additions and 3 deletions

View File

@@ -95,6 +95,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
const { data: servicesData } = await supabase.from('services').select('*');
const { data: barbersData } = await supabase.from('barbers').select('*');
const { data: productsData } = await supabase.from('products').select('*');
const fetchedShops: BarberShop[] = shopsData.map((shop) => ({
id: shop.id,
@@ -111,7 +112,14 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
duration: s.duration ?? 30,
barberIds: s.barber_ids ?? [],
})),
products: [],
products: (productsData ?? [])
.filter((p) => p.shop_id === shop.id)
.map((p) => ({
id: p.id,
name: p.name,
price: p.price ?? 0,
stock: p.stock ?? 0,
})),
barbers: (barbersData ?? [])
.filter((b) => b.shop_id === shop.id)
.map((b) => ({