From e846d9a76327eab540e5e06f812ac122f353fee1 Mon Sep 17 00:00:00 2001 From: Rohan Moniz <60864468+rm03@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:11:49 -0400 Subject: [PATCH] make apply button visible to unauthed users and enforce auth for applications --- frontend/components/ClubPage/Actions.tsx | 9 ++----- .../application/[application]/index.tsx | 8 +++++- frontend/pages/club/[club]/index.tsx | 25 ++++++++----------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/frontend/components/ClubPage/Actions.tsx b/frontend/components/ClubPage/Actions.tsx index c9a4d0d36..8d0073f48 100644 --- a/frontend/components/ClubPage/Actions.tsx +++ b/frontend/components/ClubPage/Actions.tsx @@ -12,12 +12,7 @@ import { mediaMaxWidth, mediaMinWidth, SM } from '~/constants' import { BORDER, MEDIUM_GRAY, WHITE } from '../../constants/colors' import { CLUB_APPLY_ROUTE, CLUB_EDIT_ROUTE } from '../../constants/routes' -import { - Club, - ClubApplicationRequired, - QuestionAnswer, - UserInfo, -} from '../../types' +import { Club, ClubApplicationRequired, QuestionAnswer } from '../../types' import { apiCheckPermission, apiSetLikeStatus, doApiRequest } from '../../utils' import { FIELD_PARTICIPATION_LABEL, @@ -85,7 +80,7 @@ const ActionButton = styled.a` type ActionsProps = { club: Club - userInfo: UserInfo + authenticated: boolean style?: CSSProperties className?: string updateRequests: (code: string) => Promise diff --git a/frontend/pages/club/[club]/application/[application]/index.tsx b/frontend/pages/club/[club]/application/[application]/index.tsx index 40f520f3e..69e8bd1ee 100644 --- a/frontend/pages/club/[club]/application/[application]/index.tsx +++ b/frontend/pages/club/[club]/application/[application]/index.tsx @@ -17,6 +17,7 @@ import { } from 'types' import { doApiRequest } from 'utils' +import AuthPrompt from '~/components/common/AuthPrompt' import { SelectField, TextField } from '~/components/FormComponents' type ApplicationPageProps = { @@ -107,11 +108,16 @@ export function formatQuestionType( } const ApplicationPage = ({ + userInfo, club, application, questions, initialValues, -}: ApplicationPageProps): ReactElement => { +}): ReactElement => { + if (!userInfo) { + return + } + // Second condition will be replaced with perms check or question nullity check once backend is updated // eslint-disable-next-line no-constant-condition if (new Date() < new Date(application.application_start_time) && false) { diff --git a/frontend/pages/club/[club]/index.tsx b/frontend/pages/club/[club]/index.tsx index a12a0ff31..6b8aa7e33 100644 --- a/frontend/pages/club/[club]/index.tsx +++ b/frontend/pages/club/[club]/index.tsx @@ -225,14 +225,11 @@ const ClubPage = ({ pending approval from the {APPROVAL_AUTHORITY}. )} - - {userInfo != null && ( - - )} + @@ -278,13 +275,11 @@ const ClubPage = ({ )}
- {userInfo && ( - - )} + {questions.length > 0 ? `Click here to see the ${questions.length} question${