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() {

About your company

- 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}

)}
@@ -310,11 +339,7 @@ export default function Apply() { /> {errors.isInUS && (

- {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 && ( +

+ {errors.isGenerating.message as string} +

+ )} {/* Pitch deck */}
+ {businessPitch} + Your pitch deck and other application info will be used for{" "}
@@ -401,12 +438,17 @@ export default function Apply() {
- + {errors.pitchDeck && ( +

+ {errors.pitchDeck.message as string} +

+ )} {/* What's the rough size of your community? */} -
- + {/*
+
- + +
+
*/} + + + What's the rough size of your
community? + + } + fieldName="communitySize" + choices={communitySize} + handleFunction={handleFieldChange} + description={ + <> + {" "} Include your email list, social media following (i.e. Instagram,
Discord, Facebook, Twitter, TikTok). We’d like to understand the
rough size of your current audience. - -
- + + } + placeholder="Select" + selectLabel="Select" + /> + {errors.communitySize && ( +

+ {errors.communitySize.message as string} +

+ )}