correção

This commit is contained in:
2026-03-03 15:19:29 +00:00
parent b41fc3e19b
commit d4d7018c4a

View File

@@ -114,7 +114,17 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
barbers: [],
}));
setState((s) => ({ ...s, shops: fetchedShops, shopsReady: true }));
setState((s) => {
// Preservar lojas criadas localmente que ainda não apareceram no fetch
const existingLocalShops = s.shops.filter(
(localShop) => !fetchedShops.some((fs) => fs.id === localShop.id)
);
return {
...s,
shops: [...fetchedShops, ...existingLocalShops],
shopsReady: true
};
});
} catch (err) {
console.error('refreshShops error:', err);
setState((s) => ({ ...s, shopsReady: true }));