fix: Handle duplicate shop errors during synchronization and refresh the shop list.

This commit is contained in:
2026-02-27 15:12:42 +00:00
parent 8c35b8b6e0
commit f41791adb2
2 changed files with 11 additions and 1 deletions

View File

@@ -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();
});
}
}

View File

@@ -91,6 +91,9 @@ export default function Dashboard() {
} = useApp();
const shop = shops.find((s) => s.id === user?.shopId);
const [activeTab, setActiveTab] = useState<TabId>('overview');
const [period, setPeriod] = useState<keyof typeof periods>('semana');
const [appointmentView, setAppointmentView] = useState<'list' | 'calendar'>('list');