Moved completed tutorial states to session and local storage.
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useEffect } from "react";
|
||||
import { Box, HStack, SimpleGrid, Text, VStack } from "@chakra-ui/react";
|
||||
import { isSameDay, format } from "date-fns";
|
||||
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
||||
import { updateCurrDate, updateMonth } from "../../features/calender/calender";
|
||||
import { updateCurrDate, updateMonth } from "../../features/calender";
|
||||
import CalenderNav from "./CalenderNav";
|
||||
import Day from "./Day";
|
||||
|
||||
@@ -43,12 +43,12 @@ const Calender = ({
|
||||
}, [dispatch, newDate]);
|
||||
|
||||
useEffect(() => {
|
||||
console.info("Check to update date.");
|
||||
// console.info("Check to update date.");
|
||||
|
||||
const currDateObj = new Date(currDate);
|
||||
|
||||
if (!isSameDay(currDateObj, new Date())) {
|
||||
console.info("Updated date.");
|
||||
// console.info("Updated date.");
|
||||
dispatch(updateCurrDate());
|
||||
}
|
||||
}, [currDate, dispatch]);
|
||||
|
||||
@@ -1,20 +1,39 @@
|
||||
import { Box, Button, Heading } from "@chakra-ui/react";
|
||||
import { Box, Button, Heading, HStack, VStack } from "@chakra-ui/react";
|
||||
import React from "react";
|
||||
|
||||
interface TutorialProps {
|
||||
setTutorialCookie: (bool: boolean) => void;
|
||||
setTutorialComplete: () => void;
|
||||
setTempTutorialComplete: () => void;
|
||||
}
|
||||
|
||||
const Tutorial = ({ setTutorialCookie }: TutorialProps): JSX.Element => {
|
||||
const handleSetCookieButton = (): void => {
|
||||
setTutorialCookie(true);
|
||||
};
|
||||
const Tutorial = ({
|
||||
setTutorialComplete,
|
||||
setTempTutorialComplete
|
||||
}: TutorialProps): JSX.Element => {
|
||||
return (
|
||||
<Box>
|
||||
<Heading>{"Tutorial Component"}</Heading>
|
||||
<Button type="button" onClick={() => handleSetCookieButton()}>
|
||||
{"Complete Tutorial"}
|
||||
</Button>
|
||||
<VStack
|
||||
h="auto"
|
||||
w="100%"
|
||||
justifyContent="center"
|
||||
alignContent="center"
|
||||
spacing={6}
|
||||
>
|
||||
<Heading>{"Tutorial Component"}</Heading>
|
||||
<HStack
|
||||
h="auto"
|
||||
w="80%"
|
||||
justifyContent="space-between"
|
||||
alignContent="center"
|
||||
>
|
||||
<Button type="button" onClick={() => setTutorialComplete()}>
|
||||
{"Complete Tutorial (remember)"}
|
||||
</Button>
|
||||
<Button type="button" onClick={() => setTempTutorialComplete()}>
|
||||
{"Complete Tutorial"}
|
||||
</Button>
|
||||
</HStack>
|
||||
</VStack>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user