Style updates

This commit is contained in:
Sean Edmunds
2025-02-11 15:23:48 -06:00
parent b62ad44358
commit bfd958d78f
19 changed files with 574 additions and 702 deletions

View File

@@ -178,6 +178,25 @@ export function useWeatherAPI({
});
}
export function useSunStateAPI({ lat, lon }: { lat: number; lon: number }) {
const date = new Date();
const today = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
date.setDate(date.getDate() + 1);
const tomorrow = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
const url = `https://api.sunrisesunset.io/json?lat=${lat}&lng=${lon}&date_start=${today}&date_end=${tomorrow}`;
const callEndpoint = async () => {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`${response.status} ${response.statusText}`);
}
return await response.json();
};
return useQuery({
queryKey: ['GET', url],
queryFn: () => callEndpoint(),
});
}
export function useOSMAPI({ address }: { address: string }) {
const url = `https://nominatim.openstreetmap.org/search?addressdetails=1&format=jsonv2&limit=1&q=${address?.replaceAll(' ', '+')}`;
const callEndpoint = async () => {