Skip to content

Commit

Permalink
update cookies code + removing unused comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KobeZ123 committed Oct 29, 2024
1 parent 66a7584 commit 2e2504e
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions packages/frontend/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,13 @@ const courseDndCollisisonAlgorithm: CollisionDetection = (args) => {
const HomePage: NextPage = () => {
const { error, student, mutateStudent } = useStudentWithPlans();
const router = useRouter();

// How we keep track if the modal is open or closed
const [isOpen, setIsOpen] = useState(false);
const cookies = new Cookies();
// useEffect(() => {
// setIsOpen(true); // Show the modal when the component renders
// }, []);

// when the modal closes
// useEffect(() => {
// const cookies = new Cookies();
// const existingToken = cookies.get('FeedbackModal JWT');
// if (existingToken) {
// setIsOpen(false); // Don't show the modal
// } else {
// setIsOpen(true);
// const newtoken = 'alreadyShowedModal';
// cookies.set('FeedbackModal JWT', newtoken, { path: '/' });
// // Show the modal
// }
// }, []);

useEffect(() => {
const existingToken = cookies.get("FeedbackModal JWT");
const existingToken = cookies.get("WhatsNewModal JWT");

if (!existingToken) {
setIsOpen(true); // Open modal only if token doesn't exist
Expand All @@ -101,11 +85,9 @@ const HomePage: NextPage = () => {
setIsOpen(false); // Close the modal when user dismisses it
const cookies = new Cookies();
const newToken = "alreadyShowedModal";
cookies.set("FeedbackModal JWT", newToken, { path: "/" }); // Set the token when user closes the modal
cookies.set("WhatsNewModal JWT", newToken, { path: "/" }); // Set the token when user closes the modal
};

// const onClose = () => setIsOpen(false);

/*
* Keep track of the plan being displayed, initially undef and later either the plan id or null.
* undef is used to indicate the initial state where the primary plan should be used, null is to define
Expand Down Expand Up @@ -365,12 +347,7 @@ const HomePage: NextPage = () => {
) : null}
</DragOverlay>

<WhatsNewPopUp
isOpen={isOpen}
onClose={handleClose}
// handleCancel
//() => setIsOpen(false)
/>
<WhatsNewPopUp isOpen={isOpen} onClose={handleClose} />
</DndContext>
);
};
Expand Down

0 comments on commit 2e2504e

Please sign in to comment.