From 775ad2d935a0a43bc4bc4f5b7d57ad1bda8b8618 Mon Sep 17 00:00:00 2001 From: houseassassin Date: Sun, 10 May 2026 12:54:28 +0300 Subject: [PATCH] fix: usePricing handles DB errors and clears loading on failure --- src/hooks/usePricing.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hooks/usePricing.js b/src/hooks/usePricing.js index 00ff4a6..27a7ca1 100644 --- a/src/hooks/usePricing.js +++ b/src/hooks/usePricing.js @@ -10,8 +10,8 @@ export function usePricing() { .from('settings') .select('key, value') .in('key', ['price_200', 'price_300']) - .then(({ data }) => { - if (data) { + .then(({ data, error }) => { + if (!error && data) { const map = {}; data.forEach(({ key, value }) => { const thickness = parseInt(key.replace('price_', ''), 10); @@ -20,7 +20,8 @@ export function usePricing() { setPrices((prev) => ({ ...prev, ...map })); } setLoading(false); - }); + }) + .catch(() => setLoading(false)); }, []); return { prices, loading };