Added localstorage data
This commit is contained in:
@@ -26,7 +26,14 @@ export function Homepage() {
|
||||
const [displayedGreeting, setDisplayedGreeting] = useState('');
|
||||
const [weatherModalOpened, { open: openWeatherModal, close: closeWeatherModal }] =
|
||||
useDisclosure(false);
|
||||
const { appFilter, bookmarkFilter, isMobile } = useCommonHooks();
|
||||
const {
|
||||
appFilter,
|
||||
bookmarkFilter,
|
||||
isMobile,
|
||||
setCurrentUser,
|
||||
currentLocation,
|
||||
setCurrentLocation,
|
||||
} = useCommonHooks();
|
||||
const dateOptions: Intl.DateTimeFormatOptions = !isMobile
|
||||
? {
|
||||
weekday: 'long',
|
||||
@@ -36,7 +43,6 @@ export function Homepage() {
|
||||
}
|
||||
: {};
|
||||
const date = new Date().toLocaleDateString('en-US', dateOptions);
|
||||
|
||||
useEffect(() => {
|
||||
if (messageData && isMessagesFetched) {
|
||||
setMessages(messageData);
|
||||
@@ -44,6 +50,7 @@ export function Homepage() {
|
||||
}, [messageData, isMessagesFetched]);
|
||||
useEffect(() => {
|
||||
if (personal && personalIsFetched) {
|
||||
setCurrentUser(personal[0]);
|
||||
setPersonalData(personal);
|
||||
}
|
||||
}, [personal, personalIsFetched]);
|
||||
@@ -71,30 +78,31 @@ export function Homepage() {
|
||||
const { data: weatherMetadata } = useOSMAPI({ address: personal?.[0].physicalAddress });
|
||||
const { data: points } = useWeatherAPI({
|
||||
endpoint: 'points',
|
||||
lat: weatherMetadata?.[0].lat || 0,
|
||||
lon: weatherMetadata?.[0].lon || 0,
|
||||
lat: weatherMetadata?.[0].lat || currentLocation.lat,
|
||||
lon: weatherMetadata?.[0].lon || currentLocation.lon,
|
||||
});
|
||||
const { data: basicWeather } = useWeatherAPI({
|
||||
endpoint: 'baseline',
|
||||
office: points?.properties.gridId,
|
||||
x: points?.properties.gridX,
|
||||
y: points?.properties.gridY,
|
||||
office: points?.properties.gridId || currentLocation.office,
|
||||
x: points?.properties.gridX || currentLocation.x,
|
||||
y: points?.properties.gridY || currentLocation.y,
|
||||
});
|
||||
const { data: stations } = useWeatherAPI({
|
||||
endpoint: 'stations',
|
||||
office: points?.properties.gridId,
|
||||
x: points?.properties.gridX,
|
||||
y: points?.properties.gridY,
|
||||
office: points?.properties.gridId || currentLocation.office,
|
||||
x: points?.properties.gridX || currentLocation.x,
|
||||
y: points?.properties.gridY || currentLocation.y,
|
||||
});
|
||||
const { data: weather } = useWeatherAPI({
|
||||
endpoint: 'current',
|
||||
station: stations?.features[0].properties.stationIdentifier,
|
||||
station:
|
||||
stations?.features[0].properties.stationIdentifier || currentLocation.station,
|
||||
});
|
||||
const { data: forecast } = useWeatherAPI({
|
||||
endpoint: 'forecast',
|
||||
office: points?.properties.gridId,
|
||||
x: points?.properties.gridX,
|
||||
y: points?.properties.gridY,
|
||||
office: points?.properties.gridId || currentLocation.office,
|
||||
x: points?.properties.gridX || currentLocation.x,
|
||||
y: points?.properties.gridY || currentLocation.y,
|
||||
});
|
||||
const [current, setCurrent] = useState<CurrentWeather>({
|
||||
icon: '',
|
||||
@@ -145,7 +153,6 @@ export function Homepage() {
|
||||
});
|
||||
}
|
||||
}, [weather, basicWeather]);
|
||||
|
||||
useEffect(() => {
|
||||
if (forecast) {
|
||||
setOutlook([
|
||||
@@ -172,9 +179,16 @@ export function Homepage() {
|
||||
windDirection: forecast.properties.periods[1].windDirection,
|
||||
},
|
||||
]);
|
||||
setCurrentLocation({
|
||||
office: points?.properties.gridId,
|
||||
station: stations?.features[0].properties.stationIdentifier,
|
||||
x: points?.properties.gridX,
|
||||
y: points?.properties.gridY,
|
||||
lat: weatherMetadata?.[0].lat,
|
||||
lon: weatherMetadata?.[0].lon,
|
||||
});
|
||||
}
|
||||
}, [forecast]);
|
||||
|
||||
return (
|
||||
<Stack gap={0} className={stackClasses.containerStack} justify='center'>
|
||||
<Search
|
||||
@@ -182,7 +196,6 @@ export function Homepage() {
|
||||
outlook={outlook}
|
||||
weather={weather}
|
||||
basicWeather={basicWeather}
|
||||
points={points}
|
||||
weatherModalOpened={weatherModalOpened}
|
||||
closeWeatherModal={closeWeatherModal}
|
||||
openWeatherModal={openWeatherModal}
|
||||
@@ -195,7 +208,6 @@ export function Homepage() {
|
||||
outlook={outlook}
|
||||
weather={weather}
|
||||
basicWeather={basicWeather}
|
||||
points={points}
|
||||
weatherModalOpened={weatherModalOpened}
|
||||
closeWeatherModal={closeWeatherModal}
|
||||
openWeatherModal={openWeatherModal}
|
||||
|
||||
Reference in New Issue
Block a user