From 34893f86d28ad8a7b59bcf322ff0aba4ffdbf5f3 Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Tue, 3 Mar 2026 16:52:34 +0000 Subject: [PATCH] =?UTF-8?q?mudan=C3=A7a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/context/AppContext.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web/src/context/AppContext.tsx b/web/src/context/AppContext.tsx index bb4de1d..008d759 100644 --- a/web/src/context/AppContext.tsx +++ b/web/src/context/AppContext.tsx @@ -442,15 +442,21 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { }; const updateShopDetails: AppContextValue['updateShopDetails'] = async (shopId, payload) => { - // Apenas enviar campos escalares para o Supabase (sem arrays de services/products/barbers) - const { services, products, barbers, id: _id, ...dbPayload } = payload as any; + // Remover arrays relacionais que não são colunas na tabela shops + const { services, products, barbers, id: _id, imageUrl, ...rest } = payload as any; + + // Construir o payload para o Supabase com os nomes de colunas corretos (snake_case) + const dbPayload: any = { ...rest }; + if (imageUrl !== undefined) { + dbPayload.image_url = imageUrl; // A coluna na BD chama-se image_url + } const { error } = await supabase.from('shops').update(dbPayload).eq('id', shopId); if (error) { console.error('updateShopDetails error:', error); } - // Sempre atualiza o estado local independentemente do resultado DB + // Sempre atualiza o estado local (inclui imageUrl para o frontend) setState((s) => ({ ...s, shops: s.shops.map((shop) => (shop.id === shopId ? { ...shop, ...payload } : shop)),