From f41791adb2ab03044f09641ecb32ce4d4eff8d11 Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Fri, 27 Feb 2026 15:12:42 +0000 Subject: [PATCH] fix: Handle duplicate shop errors during synchronization and refresh the shop list. --- web/src/context/AppContext.tsx | 9 ++++++++- web/src/pages/Dashboard.tsx | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/web/src/context/AppContext.tsx b/web/src/context/AppContext.tsx index 2ffbcf5..66a7183 100644 --- a/web/src/context/AppContext.tsx +++ b/web/src/context/AppContext.tsx @@ -184,7 +184,14 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { rating: 0 } ]).then(({ error }) => { - if (error) console.error("Erro ao sincronizar shop nova na BD:", error); + if (error) { + // Ignora o erro de duplicado (shop já existe na BD) + if (error.code !== '23505') { + console.error("Erro ao sincronizar shop nova na BD:", error); + } + } + // Recarrega shops da BD para garantir que a nova shop aparece corretamente + void refreshShops(); }); } } diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx index e6aca82..f9f090a 100644 --- a/web/src/pages/Dashboard.tsx +++ b/web/src/pages/Dashboard.tsx @@ -91,6 +91,9 @@ export default function Dashboard() { } = useApp(); const shop = shops.find((s) => s.id === user?.shopId); + + + const [activeTab, setActiveTab] = useState('overview'); const [period, setPeriod] = useState('semana'); const [appointmentView, setAppointmentView] = useState<'list' | 'calendar'>('list');