@kadconsulting/dry
Version:
KAD Reusable Component Library
25 lines • 893 B
JavaScript
// @ts-nocheck
import { useState, useEffect } from 'react';
import { fetchLocationsPageData, } from '../api/fetchData';
export const useLocationsPageData = () => {
const [locationsSections, setLocationsSections] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchLocationsData = async () => {
setLoading(true);
try {
const response = await fetchLocationsPageData();
setLocationsSections(response?.data?.attributes || null);
}
catch (error) {
console.error('Failed to fetch locations page data', error);
}
finally {
setLoading(false);
}
};
fetchLocationsData();
}, []);
return { locationsSections, loading };
};
//# sourceMappingURL=useLocationsPageData.js.map