From 56eca5ccee0a2d184ec9444cfa9525763313125b Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Tue, 17 Mar 2026 17:18:19 +0000 Subject: [PATCH] feat: populate shop settings form with schedule, payment methods, social networks, and contacts from shop context --- web/src/context/AppContext.tsx | 4 ++++ web/src/pages/Dashboard.tsx | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/web/src/context/AppContext.tsx b/web/src/context/AppContext.tsx index 01ea9d0..a1a2d3a 100644 --- a/web/src/context/AppContext.tsx +++ b/web/src/context/AppContext.tsx @@ -106,6 +106,10 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { address: shop.address ?? '', rating: shop.rating ?? 0, imageUrl: shop.image_url ?? shop.imageUrl ?? undefined, + schedule: shop.schedule, + paymentMethods: shop.payment_methods, + socialNetworks: shop.social_networks, + contacts: shop.contacts, services: (servicesData ?? []) .filter((s) => s.shop_id === shop.id) .map((s) => ({ diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx index ce72b2b..d443f70 100644 --- a/web/src/pages/Dashboard.tsx +++ b/web/src/pages/Dashboard.tsx @@ -4,7 +4,7 @@ * Consolida a visualização de Agendamentos, Histórico, Pedidos (produtos), * Gestão de Serviços/Produtos e Perfis de Barbeiros numa única view complexa. */ -import { useMemo, useState } from 'react'; +import { useMemo, useState, useEffect } from 'react'; import { Card } from '../components/ui/card'; import { Button } from '../components/ui/button'; import { Input } from '../components/ui/input'; @@ -162,6 +162,20 @@ function DashboardInner({ shop }: { shop: BarberShop }) { const [isSavingSettings, setIsSavingSettings] = useState(false); const [showSaveSuccess, setShowSaveSuccess] = useState(false); + useEffect(() => { + if (shop) { + setEditShopName(shop.name || ''); + setEditShopAddress(shop.address || ''); + setEditPaymentMethods(shop.paymentMethods?.join(', ') || 'Dinheiro, Cartão de Crédito, Cartão de Débito'); + setEditSocials(shop.socialNetworks || { whatsapp: '', instagram: '', facebook: '' }); + setEditContacts(shop.contacts || { phone1: '', phone2: '' }); + + if (shop.schedule && shop.schedule.length > 0) { + setEditSchedule(shop.schedule); + } + } + }, [shop]); + const periodMatch = periods[period]; // Agendamentos filtrados pela barbearia logada e pela janela de tempo selecionada