From d4d7018c4aae4bf42fa8c5c3949f17e01df0aaa6 Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Tue, 3 Mar 2026 15:19:29 +0000 Subject: [PATCH] =?UTF-8?q?corre=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/context/AppContext.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 }));