fix: usePricing handles DB errors and clears loading on failure

This commit is contained in:
2026-05-10 12:54:28 +03:00
parent c0d9732706
commit 775ad2d935
+4 -3
View File
@@ -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 };