diff --git a/web/src/context/AppContext.tsx b/web/src/context/AppContext.tsx index ceb2e59..0a02a3c 100644 --- a/web/src/context/AppContext.tsx +++ b/web/src/context/AppContext.tsx @@ -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 }));