diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx index e3f40ed..3416dfb 100644 --- a/web/src/pages/Dashboard.tsx +++ b/web/src/pages/Dashboard.tsx @@ -154,15 +154,28 @@ function DashboardInner({ shop }: { shop: BarberShop }) { const [editPaymentMethods, setEditPaymentMethods] = useState(shop.paymentMethods?.join(', ') || 'Dinheiro, Cartão de Crédito, Cartão de Débito'); const [editSocials, setEditSocials] = useState(shop.socialNetworks || { whatsapp: '', instagram: '', facebook: '' }); const [editContacts, setEditContacts] = useState(shop.contacts || { phone1: '', phone2: '' }); - const [editSchedule, setEditSchedule] = useState(shop.schedule || [ - { day: 'Segunda-feira', open: '09:00', close: '19:30' }, - { day: 'Terça-feira', open: '09:00', close: '19:30' }, - { day: 'Quarta-feira', open: '09:00', close: '19:30' }, - { day: 'Quinta-feira', open: '09:00', close: '19:30' }, - { day: 'Sexta-feira', open: '09:00', close: '19:30' }, - { day: 'Sábado', open: '09:00', close: '19:00' }, - { day: 'Domingo', open: '', close: '', closed: true }, - ]); + const [editSchedule, setEditSchedule] = useState(() => { + const sched = shop.schedule || [ + { day: 'Segunda-feira', open: '09:00', close: '19:30' }, + { day: 'Terça-feira', open: '09:00', close: '19:30' }, + { day: 'Quarta-feira', open: '09:00', close: '19:30' }, + { day: 'Quinta-feira', open: '09:00', close: '19:30' }, + { day: 'Sexta-feira', open: '09:00', close: '19:30' }, + { day: 'Sábado', open: '09:00', close: '19:00' }, + { day: 'Domingo', open: '', close: '', closed: true }, + ]; + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); + const day = String(now.getDate()).padStart(2, '0'); + const todayStr = `${year}-${month}-${day}`; + return sched.filter(s => { + if (s.isException && s.date) { + return s.date >= todayStr; + } + return true; + }); + }); const [isSavingSettings, setIsSavingSettings] = useState(false); const [showSaveSuccess, setShowSaveSuccess] = useState(false); @@ -176,7 +189,18 @@ function DashboardInner({ shop }: { shop: BarberShop }) { setEditContacts(shop.contacts || { phone1: '', phone2: '' }); if (shop.schedule && shop.schedule.length > 0) { - setEditSchedule(shop.schedule); + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); + const day = String(now.getDate()).padStart(2, '0'); + const todayStr = `${year}-${month}-${day}`; + const filtered = shop.schedule.filter(s => { + if (s.isException && s.date) { + return s.date >= todayStr; + } + return true; + }); + setEditSchedule(filtered); } } }, [shop]); @@ -191,7 +215,7 @@ function DashboardInner({ shop }: { shop: BarberShop }) { // Pedidos apenas com produtos (não serviços) const shopOrders = orders.filter( - (o) => o.shopId === shop.id && periodMatch(new Date(o.createdAt)) + (o) => o.shopId === shop.id && o.status !== 'concluido' && periodMatch(new Date(o.createdAt)) ); const pendingOrders = orders.filter((o) => o.shopId === shop.id && o.status === 'pendente').length; @@ -999,9 +1023,9 @@ function DashboardInner({ shop }: { shop: BarberShop }) { value={o.status} onChange={(e) => updateOrderStatus(o.id, e.target.value as any)} > - {['pendente', 'confirmado', 'concluido', 'cancelado'].map((s) => ( + {['pendente', 'concluido'].map((s) => ( ))}