feat: populate shop settings form with schedule, payment methods, social networks, and contacts from shop context
This commit is contained in:
@@ -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) => ({
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user