Added localstorage data
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user