Added localstorage data

This commit is contained in:
Sean Edmunds
2025-01-31 15:16:42 -06:00
parent 9430db990b
commit cc46bb0402
5 changed files with 72 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
import { Group, Stack, Text } from '@mantine/core';
import { WeatherModal } from 'components';
import { useCommonHooks, useQueryAPI } from 'hooks';
import { useCommonHooks } from 'hooks';
import { useEffect, useState } from 'react';
import { textClasses } from 'styles';
@@ -12,17 +12,12 @@ function Header({
outlook,
weather,
basicWeather,
points,
weatherModalOpened,
closeWeatherModal,
openWeatherModal,
}: any) {
const { data: personal, isFetched: personalIsFetched } = useQueryAPI({
endpoint: 'api/personalData',
});
const [personalData, setPersonalData] = useState<any>([]);
const [time, setTime] = useState(new Date());
const { isMobile } = useCommonHooks();
const { isMobile, currentUser } = useCommonHooks();
function fixDigits(k: any) {
if (k < 10) {
@@ -38,12 +33,6 @@ function Header({
}, 1000);
}, []);
useEffect(() => {
if (personal && personalIsFetched) {
setPersonalData(personal);
}
}, [personal, personalIsFetched]);
useEffect(() => {
if (weather !== undefined && basicWeather !== undefined) {
setCurrent({
@@ -92,10 +81,10 @@ function Header({
fz={isMobile ? 24 : undefined}
>
{greet
.replace('$firstName', personalData?.[0]?.firstName)
.replace('$lastName', personalData?.[0]?.lastName)
.replace('$firstName!', personalData?.[0]?.firstName.toUpperCase())
.replace('$lastName!', personalData?.[0]?.lastName.toUpperCase())}
.replace('$firstName', currentUser.firstName)
.replace('$lastName', currentUser.lastName)
.replace('$firstName!', currentUser.firstName.toUpperCase())
.replace('$lastName!', currentUser.lastName.toUpperCase())}
</Text>
</Stack>
<Stack
@@ -165,7 +154,6 @@ function Header({
<WeatherModal
current={current}
outlook={outlook}
points={points}
closeWeatherModal={closeWeatherModal}
weatherModalOpened={weatherModalOpened}
/>