From d2dfc7cd082ac7b74a89418e62620e5f4be09eba Mon Sep 17 00:00:00 2001 From: Tze Zhe Brandon Lim Date: Fri, 8 Dec 2023 20:56:59 -0500 Subject: [PATCH] Signin as guest (#677) * Update all api calls to work with guest * Add in setting of state * Fix linting errors * really fix linting errors --- .../AddCourseModal/AddCourseButton.tsx | 26 ++-------- .../components/Authentication/AuthForm.tsx | 23 ++++++++- .../components/Button/SecondaryBlueButton.tsx | 30 +++++++++++ .../Error/ConfirmEmailWarningModal.tsx | 9 ++-- .../components/Plan/AddPlanModal.tsx | 51 +++++++++++++++---- .../components/Plan/DeletePlanModal.tsx | 26 ++++++++-- .../components/Plan/EditPlanModal.tsx | 37 +++++++++++--- .../components/Plan/TransferCourses.tsx | 14 ++++- packages/frontend-v2/hooks/useLocalStorage.ts | 9 ++-- .../hooks/useRedirectIfLoggedIn.ts | 5 +- .../frontend-v2/hooks/useStudentWithPlans.ts | 29 ++++++++--- packages/frontend-v2/pages/_app.tsx | 26 +++++++--- packages/frontend-v2/pages/home.tsx | 44 ++++++++++++++-- packages/frontend-v2/pages/login.tsx | 4 ++ packages/frontend-v2/pages/signup.tsx | 4 ++ packages/frontend-v2/utils/constants.ts | 23 +++++++++ 16 files changed, 289 insertions(+), 71 deletions(-) create mode 100644 packages/frontend-v2/components/Button/SecondaryBlueButton.tsx diff --git a/packages/frontend-v2/components/AddCourseModal/AddCourseButton.tsx b/packages/frontend-v2/components/AddCourseModal/AddCourseButton.tsx index 61af22169..3b4de4031 100644 --- a/packages/frontend-v2/components/AddCourseModal/AddCourseButton.tsx +++ b/packages/frontend-v2/components/AddCourseModal/AddCourseButton.tsx @@ -1,5 +1,6 @@ import { AddIcon } from "@chakra-ui/icons"; -import { Button, ButtonProps } from "@chakra-ui/react"; +import { ButtonProps } from "@chakra-ui/react"; +import { SecondaryBlueButton } from "../Button/SecondaryBlueButton"; interface AddCourseButtonProps { onOpen: () => void; @@ -9,32 +10,13 @@ export const AddCourseButton: React.FC = ({ onOpen, ...buttonProps }) => { - const hoverStyle = { - borderColor: "neutral.300", - }; - - const activeStyle = { - backgroundColor: "neutral.200", - borderColor: "neutral.200", - }; - return ( - + ); }; diff --git a/packages/frontend-v2/components/Authentication/AuthForm.tsx b/packages/frontend-v2/components/Authentication/AuthForm.tsx index 65d1d44e7..710142b0e 100644 --- a/packages/frontend-v2/components/Authentication/AuthForm.tsx +++ b/packages/frontend-v2/components/Authentication/AuthForm.tsx @@ -1,5 +1,8 @@ -import { Flex, Heading } from "@chakra-ui/react"; -import { FormEventHandler, ReactNode } from "react"; +import { AbsoluteCenter, Box, Divider, Flex, Heading } from "@chakra-ui/react"; +import router from "next/router"; +import { FormEventHandler, ReactNode, useContext } from "react"; +import { SecondaryBlueButton } from "../Button/SecondaryBlueButton"; +import { IsGuestContext } from "../../pages/_app"; type NewType = ReactNode; @@ -15,6 +18,7 @@ export const AuthForm: React.FC = ({ inputs, footer, }) => { + const { setIsGuest } = useContext(IsGuestContext); return ( = ({ {inputs} {footer} + + + + or + + + { + setIsGuest(true); + router.push("/home"); + }} + > + Continue as Guest + ); }; diff --git a/packages/frontend-v2/components/Button/SecondaryBlueButton.tsx b/packages/frontend-v2/components/Button/SecondaryBlueButton.tsx new file mode 100644 index 000000000..49de2fdb3 --- /dev/null +++ b/packages/frontend-v2/components/Button/SecondaryBlueButton.tsx @@ -0,0 +1,30 @@ +import { ButtonProps, Button, ComponentWithAs } from "@chakra-ui/react"; + +export const SecondaryBlueButton: ComponentWithAs<"button", ButtonProps> = ({ + ...buttonProps +}) => { + const hoverStyle = { + borderColor: "neutral.300", + }; + + const activeStyle = { + backgroundColor: "neutral.200", + borderColor: "neutral.200", + }; + + return ( +