From 18d64d82c55066849804614b89f43e38b93ee39a Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 7 Oct 2025 09:43:52 +0100 Subject: [PATCH] add robotics url params to prefill FIRST/Robotics (#1646) --- .../apply/application-form.js | 51 +++++++++++++++++-- .../fiscal-sponsorship/apply/org-form.js | 37 ++++++++++---- pages/api/fiscal-sponsorship/apply.js | 4 +- pages/fiscal-sponsorship/apply/index.js | 17 +++++-- 4 files changed, 90 insertions(+), 19 deletions(-) diff --git a/components/fiscal-sponsorship/apply/application-form.js b/components/fiscal-sponsorship/apply/application-form.js index 9c92c167..4b8c0d13 100644 --- a/components/fiscal-sponsorship/apply/application-form.js +++ b/components/fiscal-sponsorship/apply/application-form.js @@ -1,5 +1,5 @@ import { useRouter } from 'next/router' -import { useRef, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { Alert, Button, Text } from 'theme-ui' import FormContainer from './form-container' import OrganizationInfoForm from './org-form' @@ -11,8 +11,10 @@ import MultiStepForm from './multi-step-form' export default function ApplicationForm() { const router = useRouter() const formContainer = useRef() + const roboticsPriorityCheckbox = useRef(null) const [formError, setFormError] = useState(null) const [isSubmitting, setIsSubmitting] = useState(false) + const [roboticsPriorityEnabled, setRoboticsPriorityEnabled] = useState(false) const requiredFields = { // Key: form field name @@ -58,6 +60,30 @@ export default function ApplicationForm() { ) + // Prefill hidden Robotics Priority field from query params or saved progress + useEffect(() => { + if (!roboticsPriorityCheckbox.current || !router.isReady) return + + const queryValueRaw = router.query['robotics-priority'] + const queryValue = Array.isArray(queryValueRaw) + ? queryValueRaw[queryValueRaw.length - 1] + : queryValueRaw + + const shouldCheck = + typeof queryValue === 'string' && + ['true', '1', 'yes', 'on'].includes(queryValue.toLowerCase()) + + roboticsPriorityCheckbox.current.checked = shouldCheck + setRoboticsPriorityEnabled(shouldCheck) + + if (typeof window !== 'undefined') { + sessionStorage.setItem( + 'bank-signup-robotics-priority', + shouldCheck ? 'true' : 'false' + ) + } + }, [router.isReady, router.query]) + return ( + + - Fill out this quick application to run your project on HCB. If you - are a teenager, there is a very high likelihood we will accept your - project. We just need to collect a few pieces of information first. + Fill out this quick application to run your{' '} + {roboticsPriorityEnabled ? 'robotics team' : 'project'} on HCB. If + you are a teenager, there is a very high likelihood we will accept{' '} + your project. We just need to collect a few pieces of information + first. {/* Step 2 */} - + {/* Step 3 */} diff --git a/components/fiscal-sponsorship/apply/org-form.js b/components/fiscal-sponsorship/apply/org-form.js index 1badb6f3..ab36e2c5 100644 --- a/components/fiscal-sponsorship/apply/org-form.js +++ b/components/fiscal-sponsorship/apply/org-form.js @@ -7,8 +7,24 @@ import useOrganizationI18n from '../organizationI18n' import OrganizationAdultForm from './org-adult-form' import { useTeenagerLedContext } from './teenager-led-context' -export default function OrganizationInfoForm({ requiredFields }) { +export default function OrganizationInfoForm({ + requiredFields, + roboticsPriorityEnabled = false +}) { const org = useOrganizationI18n() + const nameLabel = roboticsPriorityEnabled ? 'Team name and number' : `${org} name` + const descriptionLabel = roboticsPriorityEnabled + ? 'Tell us about your robotics team' + : `Tell us about your ${org.toLowerCase()}` + const descriptionCaption = roboticsPriorityEnabled + ? "What leagues are you in? Are you affiliated with any schools? What's the history of your robotics team?" + : 'Are you running a hackathon, robotics team, organizing a nonprofit, building a project, etc.?' + const websiteQuestionLabel = roboticsPriorityEnabled + ? 'Does your robotics team have a website?' + : 'Does your project have a website?' + const websiteFieldLabel = roboticsPriorityEnabled + ? 'Team website' + : `${org} website` const { teenagerLed } = useTeenagerLedContext() @@ -50,25 +66,26 @@ export default function OrganizationInfoForm({ requiredFields }) { <> - - Are you running a hackathon, robotics team, organizing a nonprofit, - building a project, etc.? - + {descriptionCaption}