From 9b8a4e02b92dcbebe6dc0f0c307941d11f79fa2a Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Thu, 12 Mar 2026 10:22:29 +0000 Subject: [PATCH] =?UTF-8?q?corre=C3=A7=C3=A3o=20de=20erro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/context/AppContext.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/web/src/context/AppContext.tsx b/web/src/context/AppContext.tsx index 16ff9bd..930156e 100644 --- a/web/src/context/AppContext.tsx +++ b/web/src/context/AppContext.tsx @@ -493,8 +493,10 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { const { error } = await supabase.from('services').insert([ { shop_id: shopId, name: service.name, price: service.price, duration: service.duration } ]); - if (error) console.error("Erro addService:", error); - else await refreshShops(); + if (error) { + console.error("Erro addService:", error); + alert(`Erro ao guardar serviço: ${error.message}`); + } else await refreshShops(); }; const updateService: AppContextValue['updateService'] = async (shopId, service) => { @@ -515,8 +517,10 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { const { error } = await supabase.from('products').insert([ { shop_id: shopId, name: product.name, price: product.price, stock: product.stock } ]); - if (error) console.error("Erro addProduct:", error); - else await refreshShops(); + if (error) { + console.error("Erro addProduct:", error); + alert(`Erro ao guardar produto: ${error.message}`); + } else await refreshShops(); }; const updateProduct: AppContextValue['updateProduct'] = async (shopId, product) => { @@ -537,8 +541,10 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => { const { error } = await supabase.from('barbers').insert([ { shop_id: shopId, name: barber.name, specialties: barber.specialties } ]); - if (error) console.error("Erro addBarber:", error); - else await refreshShops(); + if (error) { + console.error("Erro addBarber:", error); + alert(`Erro ao guardar barbeiro: ${error.message}`); + } else await refreshShops(); }; const updateBarber: AppContextValue['updateBarber'] = async (shopId, barber) => {