correção
This commit is contained in:
@@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user