diff --git a/src/app/components/pages/IsaacCompetition/Buttons/CompetitionButton.tsx b/src/app/components/pages/IsaacCompetition/Buttons/CompetitionButton.tsx index f4e5d2b0da..6598bac03f 100644 --- a/src/app/components/pages/IsaacCompetition/Buttons/CompetitionButton.tsx +++ b/src/app/components/pages/IsaacCompetition/Buttons/CompetitionButton.tsx @@ -16,15 +16,18 @@ const CompetitionButton = ({ buttons }: CompetitionButtonProps) => { }; const handleClick = (to: string) => { - persistence.save(KEY.AFTER_AUTH_PATH, location.pathname); + if (to.startsWith("#")) { + document.getElementById(to.slice(1))?.scrollIntoView({ behavior: "smooth" }); + return; + } if (isExternalLink(to)) { - // For external links, open in the new tab window.open(to, "_blank", "noopener, noreferrer"); - } else { - // For internal links, use React Router - history.push(to); + return; } + + persistence.save(KEY.AFTER_AUTH_PATH, location.pathname); + history.push(to); }; return ( diff --git a/src/app/components/pages/IsaacCompetition/EntryForm/CompetitionEntryForm.tsx b/src/app/components/pages/IsaacCompetition/EntryForm/CompetitionEntryForm.tsx index d90e136dc8..833ccff2fc 100644 --- a/src/app/components/pages/IsaacCompetition/EntryForm/CompetitionEntryForm.tsx +++ b/src/app/components/pages/IsaacCompetition/EntryForm/CompetitionEntryForm.tsx @@ -262,7 +262,7 @@ export const CompetitionEntryForm = ({ handleTermsClick }: CompetitionEntryFormP selectedGroup && selectedGroup.members !== undefined && !isLoadingMembers && selectedGroup.members.length === 0; return ( -
+
diff --git a/src/app/components/pages/IsaacCompetition/EntryForm/EntryFormHandler.tsx b/src/app/components/pages/IsaacCompetition/EntryForm/EntryFormHandler.tsx index 6893e1d737..ce5d6646f6 100644 --- a/src/app/components/pages/IsaacCompetition/EntryForm/EntryFormHandler.tsx +++ b/src/app/components/pages/IsaacCompetition/EntryForm/EntryFormHandler.tsx @@ -1,17 +1,28 @@ import React from "react"; import { Container, Col } from "reactstrap"; import CompetitionEntryForm from "./CompetitionEntryForm"; -import CompetitionButton from "../Buttons/CompetitionButton"; import { selectors, useAppSelector } from "../../../../state"; -import { isStudent, isAdmin, isTeacher } from "../../../../services"; +import { isStudent, isAdmin, isTeacher, isLoggedIn } from "../../../../services"; import CompetitionWrapper from "../CompetitionWrapper"; -import { CLOSED_MESSAGE, STUDENT_MESSAGE, TEACHER_MESSAGE } from "../constants"; +import { CLOSED_MESSAGE, STUDENT_MESSAGE } from "../constants"; import { isBeforeCompetitionOpenDate } from "../dateUtils"; +import { PotentialUser } from "../../../../../IsaacAppTypes"; +import { Immutable } from "immer"; -// EOI button configuration - same as HomepageHighlight -export const eoiButton = { - to: "https://forms.cloud.microsoft/e/K4GmaA3QEF", - label: isBeforeCompetitionOpenDate(new Date()) ? "Express your interest" : "Submit your project", +const EOI_FORM_URL = "https://forms.cloud.microsoft/e/K4GmaA3QEF"; +const ENTRY_FORM_ANCHOR = "#competition-entry-form"; + +export const getHeadlineCtaButton = (user?: Immutable | null) => { + const beforeOpen = isBeforeCompetitionOpenDate(new Date()); + if (beforeOpen) { + return { to: EOI_FORM_URL, label: "Express your interest" }; + } + + if (isLoggedIn(user) && (isTeacher(user) || isAdmin(user))) { + return { to: ENTRY_FORM_ANCHOR, label: "Submit your project" }; + } + + return { to: "/login", label: "Submit your project" }; }; const StudentMessage = () => ( @@ -22,25 +33,11 @@ const StudentMessage = () => ( ); -interface DefaultMessageProps { - buttons: { to: string; label: string }[]; -} - -const DefaultMessage: React.FC = ({ buttons }) => ( - - -

{TEACHER_MESSAGE}

- - -
-); - interface EntryFormHandlerProps { - buttons: { to: string; label: string }[]; handleTermsClick: (event: React.MouseEvent) => void; } -const EntryFormHandler = ({ buttons, handleTermsClick }: EntryFormHandlerProps) => { +const EntryFormHandler = ({ handleTermsClick }: EntryFormHandlerProps) => { const user = useAppSelector(selectors.user.orNull); const renderEntryForm = () => { @@ -53,9 +50,10 @@ const EntryFormHandler = ({ buttons, handleTermsClick }: EntryFormHandlerProps) ); } else if (isStudent(user)) { return ; - } else { - return ; } + + // Logged-out CTA lives in the headline (teacher copy + Submit your project) + return null; }; return ( diff --git a/src/app/components/pages/IsaacCompetition/IsaacCompetition.tsx b/src/app/components/pages/IsaacCompetition/IsaacCompetition.tsx index dc5775a9fa..72b52a71a5 100644 --- a/src/app/components/pages/IsaacCompetition/IsaacCompetition.tsx +++ b/src/app/components/pages/IsaacCompetition/IsaacCompetition.tsx @@ -7,10 +7,11 @@ import "../../../../scss/cs/competition.scss"; import Accordion from "./Accordion/Accordion"; import InformationCard from "./CompetitionInformation/InformationCard"; import CompetitionTimeline from "./CompetitionInformation/CompetitionTimeline"; -import EntryFormHandler, { eoiButton } from "./EntryForm/EntryFormHandler"; +import EntryFormHandler, { getHeadlineCtaButton } from "./EntryForm/EntryFormHandler"; import CompetitionButton from "./Buttons/CompetitionButton"; import CompetitionWrapper from "./CompetitionWrapper"; import { isBeforeCompetitionOpenDate, liveQandASessionDate } from "./dateUtils"; +import { selectors, useAppSelector } from "../../../state"; const { section1, section3, accordion } = content; @@ -19,12 +20,8 @@ export const IsaacCompetition = () => { document.title = "Isaac " + SITE_SUBJECT_TITLE; }, []); - const buttons = [ - { - to: "/login", - label: "Submit a project", - }, - ]; + const user = useAppSelector(selectors.user.orNull); + const headlineCtaButton = getHeadlineCtaButton(user); const [open, setOpen] = useState(null); @@ -103,8 +100,10 @@ export const IsaacCompetition = () => {

- - + } + > + @@ -121,7 +120,7 @@ export const IsaacCompetition = () => { - +