Address updates

This commit is contained in:
Sean Edmunds
2025-01-29 14:36:31 -06:00
parent f9cc1ab63a
commit e87f4abec9
7 changed files with 118 additions and 65 deletions

View File

@@ -2,8 +2,7 @@ import { useLocalStorage } from '@mantine/hooks';
import { appTheme } from 'contexts';
import { useAtom } from 'jotai';
import { useEffect, useState } from 'react';
import { toast } from 'react-toastify';
import { useCensusAPI, useQueryAPI, useWeatherAPI } from './useAPI';
import { useOSMAPI, useQueryAPI, useWeatherAPI } from './useAPI';
export function useCommonHooks() {
const isMobile = window.matchMedia('(max-width: 600px)').matches;
@@ -62,10 +61,7 @@ export function useCommonHooks() {
isFetching: wolClientsIsFetching,
isLoading: wolClientsIsLoading,
} = useQueryAPI({ endpoint: 'api/wolClients' });
const { data: basicWeather } = useWeatherAPI({ endpoint: 'baseline' });
const { data: weather } = useWeatherAPI({ endpoint: 'current' });
const { data: forecast } = useWeatherAPI({ endpoint: 'forecast' });
const { data: hourly } = useWeatherAPI({ endpoint: 'hourly' });
const [theme, setTheme] = useAtom(appTheme);
const [themeName, setThemeName] = useLocalStorage<any>({
key: 'theme',
@@ -102,8 +98,6 @@ export function useCommonHooks() {
const [applicationData, setApplicationData] = useState<any>([]);
const notify = (notification: any) => toast(notification, { position: 'bottom-right' });
useEffect(() => {
if (apps && !isAppsFetching) {
setApplicationData(apps);
@@ -161,17 +155,40 @@ export function useCommonHooks() {
}
}, [wolClients, wolClientsIsFetched]);
const { data: locationData } = useCensusAPI({
address: personalData?.[0]?.physicalAddress,
const { data: weatherMetadata } = useOSMAPI({ address: personal?.[0].physicalAddress });
const { data: points } = useWeatherAPI({
endpoint: 'points',
lat: weatherMetadata?.[0].lat,
lon: weatherMetadata?.[0].lon,
});
const { data: basicWeather } = useWeatherAPI({
endpoint: 'baseline',
office: points?.properties.gridId,
x: points?.properties.gridX,
y: points?.properties.gridY,
});
const { data: stations } = useWeatherAPI({
endpoint: 'stations',
office: points?.properties.gridId,
x: points?.properties.gridX,
y: points?.properties.gridY,
});
const { data: weather } = useWeatherAPI({
endpoint: 'current',
station: stations?.features[0].properties.stationIdentifier,
});
const { data: forecast } = useWeatherAPI({
endpoint: 'forecast',
office: points?.properties.gridId,
x: points?.properties.gridX,
y: points?.properties.gridY,
});
const { data: hourly } = useWeatherAPI({
endpoint: 'hourly',
office: points?.properties.gridId,
x: points?.properties.gridX,
y: points?.properties.gridY,
});
const [location, setLocation] = useState<any>([]);
useEffect(() => {
if (locationData) {
setLocation(locationData);
}
}, [locationData]);
return {
isMobile,
@@ -234,7 +251,5 @@ export function useCommonHooks() {
wolClientsIsFetched,
wolClientsIsFetching,
wolClientsIsLoading,
location,
notify,
};
}