diff --git a/src/app/business/apply/page.tsx b/src/app/business/apply/page.tsx index 17d4145..206916d 100644 --- a/src/app/business/apply/page.tsx +++ b/src/app/business/apply/page.tsx @@ -32,8 +32,8 @@ export default function Apply() { z.string().url("Pitch deck must be a valid URL."), z.object({}), ]); - - const formSchema = z.object({ + const projectFormSchema = z.object({}); + const businessFormSchema = z.object({ companyName: z.string().min(5, { message: "Company name must be at least 5 characters.", }), @@ -78,12 +78,21 @@ export default function Apply() { }); let supabase = createSupabaseClient(); const { - register, - handleSubmit, - setValue, - formState: { errors }, + register: registerBusiness, + handleSubmit: handleSubmitBusiness, + setValue: setValueBusiness, + formState: { errors: errorsBusiness }, } = useForm({ - resolver: zodResolver(formSchema), + resolver: zodResolver(businessFormSchema), + }); + + const { + register: registerProject, + handleSubmit: handleSubmitProject, + setValue: setValueProject, + formState: { errors: errorsProject }, + } = useForm({ + resolver: zodResolver(projectFormSchema), }); const [industry, setIndustry] = useState([]); const [isInUS, setIsInUS] = useState(""); @@ -106,11 +115,11 @@ export default function Apply() { ]; useEffect(() => { - register("industry"); - register("isInUS"); - register("isForSale"); - register("isGenerating"); - }, [register]); + registerBusiness("industry"); + registerBusiness("isInUS"); + registerBusiness("isForSale"); + registerBusiness("isGenerating"); + }, [registerBusiness]); const handleRemoveImage = (index: number) => { const updatedImages = selectedImages.filter((_, i) => i !== index); @@ -155,7 +164,7 @@ export default function Apply() { const handleBusinessPitchChange = (type: string) => { setBusinessPitch(type); // clear out old data - setValue("pitchDeck", ""); + setValueBusiness("pitchDeck", ""); }; const handleFieldChange = (fieldName: string, value: any) => { @@ -170,7 +179,7 @@ export default function Apply() { setIsGenerating(value); break; } - setValue(fieldName, value); + setValueBusiness(fieldName, value); }; const fetchIndustry = async () => { let { data: BusinessType, error } = await supabase @@ -222,7 +231,7 @@ export default function Apply() { {/* form */} -
+

About your company

@@ -241,18 +250,18 @@ export default function Apply() { type="text" id="companyName" className="w-96" - {...register("companyName")} + {...registerBusiness("companyName")} /> This should be the name your company uses on your
website and in the market.

- {errors.companyName && ( + {errorsBusiness.companyName && (

- {errors.companyName && ( + {errorsBusiness.companyName && (

- {errors.companyName.message as string} + {errorsBusiness.companyName.message as string}

)}

@@ -271,9 +280,9 @@ export default function Apply() { placeholder="Select an industry" selectLabel="Industry" /> - {errors.industry && ( + {errorsBusiness.industry && (

- {errors.industry.message as string} + {errorsBusiness.industry.message as string}

)} {/* How much money has your company raised to date? */} @@ -287,7 +296,7 @@ export default function Apply() { id="totalRaised" className="w-96" placeholder="$ 1,000,000" - {...register("totalRaised", { + {...registerBusiness("totalRaised", { valueAsNumber: true, })} /> @@ -297,9 +306,9 @@ export default function Apply() { capital, loans, grants, or token sales. - {errors.totalRaised && ( + {errorsBusiness.totalRaised && (

- {errors.totalRaised.message as string} + {errorsBusiness.totalRaised.message as string}

)} @@ -326,9 +335,9 @@ export default function Apply() { } value={isInUS} /> - {errors.isInUS && ( + {errorsBusiness.isInUS && (

- {errors.isInUS.message as string} + {errorsBusiness.isInUS.message as string}

)} @@ -353,9 +362,9 @@ export default function Apply() { } value={isForSale} /> - {errors.isForSale && ( + {errorsBusiness.isForSale && (

- {errors.isForSale.message as string} + {errorsBusiness.isForSale.message as string}

)} @@ -374,9 +383,9 @@ export default function Apply() { } value={isGenerating} /> - {errors.isGenerating && ( + {errorsBusiness.isGenerating && (

- {errors.isGenerating.message as string} + {errorsBusiness.isGenerating.message as string}

)} {/* Pitch deck */} @@ -413,7 +422,7 @@ export default function Apply() { : "https:// " } accept={businessPitch === "file" ? ".md" : undefined} - {...register("pitchDeck", { required: true })} + {...registerBusiness("pitchDeck", { required: true })} /> @@ -423,12 +432,16 @@ export default function Apply() { Please make sure this document is publicly accessible. This can
be a DocSend, Box, Dropbox, Google Drive or other link. +
+

+ ** support only markdown(.md) format +

- {errors.pitchDeck && ( + {errorsBusiness.pitchDeck && (

- {errors.pitchDeck.message as string} + {errorsBusiness.pitchDeck.message as string}

)} - {errors.communitySize && ( + {errorsBusiness.communitySize && (

- {errors.communitySize.message as string} + {errorsBusiness.communitySize.message as string}

)} @@ -486,233 +499,226 @@ export default function Apply() { {/* apply first project */} {applyProject && (
- {/* header */} -
-

- Begin Your First Fundraising Project -

-

- Starting a fundraising project is mandatory for all businesses. - This step is crucial
- to begin your journey and unlock the necessary tools for raising - funds. -

+ + {/* header */} +
+

+ Begin Your First Fundraising Project +

+

+ Starting a fundraising project is mandatory for all + businesses. This step is crucial
+ to begin your journey and unlock the necessary tools for + raising funds. +

- {/* project's name */} -
- -
- + {/* project's name */} +
+ +
+ +
-
- {/* project type */} -
- -
- - - Please specify the primary purpose of the funds - -
-
+ {/* project type */} + Project type} + fieldName="projectType" + choices={projectType} + handleFunction={handleFieldChange} + description={ + <>Please specify the primary purpose of the funds + } + placeholder="Select a Project type" + selectLabel="Project type" + /> - {/* short description */} -
- -
-