diff --git a/src/app/business/apply/page.tsx b/src/app/business/apply/page.tsx index 9d2c243..fe87374 100644 --- a/src/app/business/apply/page.tsx +++ b/src/app/business/apply/page.tsx @@ -28,11 +28,24 @@ import { DualOptionSelector } from "@/components/dualSelector"; import { MultipleOptionSelector } from "@/components/multipleSelector"; export default function Apply() { + const pitchDeckSchema = z + .union([ + z.string().url("Pitch deck must be a valid URL."), + z.instanceof(File).refine((file) => file.size > 0, { + message: "A file must be selected.", + }), + ]) + .refine((value) => typeof value === "string" || value instanceof File, { + message: "Pitch deck must be either a file or a URL.", + }); + const formSchema = z.object({ companyName: z.string().min(5, { message: "Company name must be at least 5 characters.", }), - industry: z.string(), + industry: z.string({ + required_error: "Please select one of the option", + }), isInUS: z .string({ required_error: "Please select either 'Yes' or 'No'.", @@ -64,6 +77,10 @@ export default function Apply() { }) .positive() .max(9999999999, "Total raised must be a realistic amount."), + communitySize: z.string({ + required_error: "Please select one of the option", + }), + pitchDeck: pitchDeckSchema, }); let supabase = createSupabaseClient(); const { @@ -133,9 +150,19 @@ export default function Apply() { }, {} ); - + if (data.pitchDeck instanceof File) { + console.log("File Uploaded:", data.pitchDeck.name); + } else { + console.log("URL Provided:", data.pitchDeck); + } alert(JSON.stringify(transformedData)); }; + const handleBusinessPitchChange = (type: string) => { + setBusinessPitch(type); + // clear out old data + setValue("pitchDeck", ""); + }; + const handleFieldChange = (fieldName: string, value: any) => { switch (fieldName) { case "isInUS": @@ -204,7 +231,8 @@ export default function Apply() {
- All requested information in this section is required. + **All requested + information in this section is required.
{/* company name */} @@ -248,6 +276,11 @@ export default function Apply() { placeholder="Select an industry" selectLabel="Industry" /> + {errors.industry && ( ++ {errors.industry.message as string} +
+ )} {/* {errors.totalRaised && (- {errors.totalRaised && ( -
- {errors.totalRaised.message as string} -
- )} + {errors.totalRaised.message as string} )}- {errors.isInUS && ( -
- {errors.isInUS.message as string} -
- )} + {errors.isInUS.message as string} )} @@ -339,6 +364,11 @@ export default function Apply() { } value={isForSale} /> + {errors.isForSale && ( ++ {errors.isForSale.message as string} +
+ )} {/* Is your company generating revenue?*/}+ {errors.isGenerating.message as string} +
+ )} {/* Pitch deck */}+ {errors.pitchDeck.message as string} +
+ )} {/* What's the rough size of your community? */} -+ {errors.communitySize.message as string} +
+ )}