From 2a9b85c9b3a1969faec6d5d570b967811b1c403e Mon Sep 17 00:00:00 2001 From: Caleb Parikh Date: Mon, 13 May 2024 16:49:52 -0600 Subject: [PATCH 01/12] added radio buttons to app form for ltff and eaif, add some questions based on cause areas --- app/create/create-project-form.tsx | 101 ++++++++++++++++++++--- components/checkbox.tsx | 126 +++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+), 13 deletions(-) create mode 100644 components/checkbox.tsx diff --git a/app/create/create-project-form.tsx b/app/create/create-project-form.tsx index 0b1bbeb1..8bdecc61 100644 --- a/app/create/create-project-form.tsx +++ b/app/create/create-project-form.tsx @@ -24,7 +24,7 @@ import { Checkbox } from '@/components/input' import { usePartialUpdater } from '@/hooks/user-partial-updater' import { ProjectParams } from '@/utils/upsert-project' -const DESCRIPTION_OUTLINE = ` +var DESCRIPTION_OUTLINE = `

Project summary


What are this project's goals and how will you achieve them?

@@ -38,8 +38,23 @@ const DESCRIPTION_OUTLINE = `

What other funding are you or your project getting?


` + +const LTFF_QUESTIONS = ` +

LTFF QUESTIONS

+
+

How will you solve x-risk?

+
+` +const EAIF_QUESTIONS = ` +

EAIF QUESTIONS

+
+

How will you solve EA community building?

+
+` + const DESCRIPTION_KEY = 'ProjectDescription' + export function CreateProjectForm(props: { causesList: Cause[] }) { const { causesList } = props const [projectParams, updateProjectParams] = usePartialUpdater( @@ -56,6 +71,8 @@ export function CreateProjectForm(props: { causesList: Cause[] }) { } ) const [isSubmitting, setIsSubmitting] = useState(false) + const [isLTFFSelected, setIsLTFFSelected] = useState(false); + const [isEAIFSelected, setIsEAIFSelected] = useState(false); const editor = useTextEditor(DESCRIPTION_OUTLINE, DESCRIPTION_KEY) const [madeChanges, setMadeChanges] = useState(false) @@ -72,17 +89,26 @@ export function CreateProjectForm(props: { causesList: Cause[] }) { (1 - (projectParams.selectedPrize?.cert_params?.defaultInvestorShares ?? 0) / - TOTAL_SHARES) * + TOTAL_SHARES) * 100, - }) + }); if (!madeChanges) { - editor?.commands.setContent( - projectParams.selectedPrize?.project_description_outline ?? - DESCRIPTION_OUTLINE - ) - setMadeChanges(false) + let descriptionOutline = projectParams.selectedPrize?.project_description_outline ?? + DESCRIPTION_OUTLINE; + if (isLTFFSelected) { + descriptionOutline += LTFF_QUESTIONS; + } + if (isEAIFSelected) { + descriptionOutline += EAIF_QUESTIONS; + } + // Check for other causes and add their custom questions + // ... + editor?.commands.setContent(descriptionOutline); + setMadeChanges(false); } - }, [projectParams.selectedPrize]) + }, [projectParams.selectedPrize, isLTFFSelected, isEAIFSelected]); // Add other cause selection state variables as dependencies + + const selectablePrizeCauses = causesList.filter( (cause) => cause.open && cause.prize ) @@ -110,7 +136,7 @@ export function CreateProjectForm(props: { causesList: Cause[] }) { body: JSON.stringify({ ...projectParams, description: finalDescription }), }) const newProject = await response.json() - router.push(`/projects/${newProject.slug}`) + router.push(`/ projects / ${newProject.slug} `) clearLocalStorageItem(DESCRIPTION_KEY) setIsSubmitting(false) } @@ -149,9 +175,7 @@ export function CreateProjectForm(props: { causesList: Cause[] }) { selectedPrize: value === 'grant' ? null - : selectablePrizeCauses.find( - (cause) => cause.slug === value - ) ?? null, + : selectablePrizeCauses.find((cause) => cause.slug === value) ?? null, }) } options={{ @@ -161,6 +185,57 @@ export function CreateProjectForm(props: { causesList: Cause[] }) { ), }} /> + + + + cause.slug === 'ltff')} + onChange={(event) => { + const { checked } = event.target; + const ltffCause = causesList.find((cause) => cause.slug === 'ltff'); + updateProjectParams({ + selectedCauses: checked + ? [...projectParams.selectedCauses, ltffCause] + : projectParams.selectedCauses.filter((cause) => cause.slug !== 'ltff'), + }); + setIsLTFFSelected(checked); + }} + /> + + LTFF Grant + + + + cause.slug === 'eaif')} + onChange={(event) => { + const { checked } = event.target; + const eaifCause = causesList.find((cause) => cause.slug === 'eaif'); + updateProjectParams({ + selectedCauses: checked + ? [...projectParams.selectedCauses, eaifCause] + : projectParams.selectedCauses.filter((cause) => cause.slug !== 'eaif'), + }); + setIsEAIFSelected(checked); + }} + /> + + EAIF Grant + + + + + +
+

Selected Causes:

+
    + {projectParams.selectedCauses.map((cause) => ( +
  • {cause.title}
  • + ))} +
+
+ +