feat: populate shop settings form with schedule, payment methods, social networks, and contacts from shop context

This commit is contained in:
2026-03-17 17:18:19 +00:00
parent e21f717f15
commit 56eca5ccee
2 changed files with 19 additions and 1 deletions

View File

@@ -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) => ({

View File

@@ -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