fix: usePricing handles DB errors and clears loading on failure
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user