From fa72de4a7c7cb4bffa4c7a1b34fdbeab577c33a6 Mon Sep 17 00:00:00 2001 From: Suraj Ramchandran <30753067+Suraj-Ram@users.noreply.github.com> Date: Sun, 21 Jan 2024 16:14:58 -0500 Subject: [PATCH] fixed linting errors --- .../components/Plan/DeleteYearModal.tsx | 5 +--- .../frontend/hooks/useRedirectIfLoggedIn.ts | 27 +++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/frontend/components/Plan/DeleteYearModal.tsx b/packages/frontend/components/Plan/DeleteYearModal.tsx index c237ef7a9..96733d27e 100644 --- a/packages/frontend/components/Plan/DeleteYearModal.tsx +++ b/packages/frontend/components/Plan/DeleteYearModal.tsx @@ -12,16 +12,14 @@ import { ModalOverlay, useDisclosure, } from "@chakra-ui/react"; -import { API } from "@graduate/api-client"; import { useRouter } from "next/router"; -import { Dispatch, SetStateAction, useContext } from "react"; +import { Dispatch, SetStateAction } from "react"; import { mutate } from "swr"; import { USE_STUDENT_WITH_PLANS_SWR_KEY, useStudentWithPlans, } from "../../hooks"; import { handleApiClientError, toast } from "../../utils"; -import { IsGuestContext } from "../../pages/_app"; import { GraduateToolTip } from "../GraduateTooltip"; interface DeleteYearModalProps { @@ -34,7 +32,6 @@ export const DeleteYearModal: React.FC = ({ }) => { const router = useRouter(); const { onOpen, onClose, isOpen } = useDisclosure(); - const { isGuest } = useContext(IsGuestContext); const { student } = useStudentWithPlans(); if (!student) { diff --git a/packages/frontend/hooks/useRedirectIfLoggedIn.ts b/packages/frontend/hooks/useRedirectIfLoggedIn.ts index 4f81f96b9..b42e40224 100644 --- a/packages/frontend/hooks/useRedirectIfLoggedIn.ts +++ b/packages/frontend/hooks/useRedirectIfLoggedIn.ts @@ -15,22 +15,21 @@ export const useRedirectIfLoggedIn = () => { const [renderSpinner, setRenderSpinner] = useState(false); const { setIsGuest } = useContext(IsGuestContext); - const loginWithCookie = async () => { - setRenderSpinner(true); - try { - await API.student.getMe(); - setIsGuest(false); - router.push("/home"); - } catch (err) { - const error = err as AxiosError; - logger.error(error); - setRenderSpinner(false); - } - }; - useEffect(() => { + const loginWithCookie = async () => { + setRenderSpinner(true); + try { + await API.student.getMe(); + setIsGuest(false); + router.push("/home"); + } catch (err) { + const error = err as AxiosError; + logger.error(error); + setRenderSpinner(false); + } + }; loginWithCookie(); - }, []); + }, [setIsGuest]); return renderSpinner; };