diff --git a/src/app/business/apply/page.tsx b/src/app/business/apply/page.tsx index 44ed393..98ba82b 100644 --- a/src/app/business/apply/page.tsx +++ b/src/app/business/apply/page.tsx @@ -6,7 +6,7 @@ import { Switch } from "@/components/ui/switch"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; import { useEffect, useState } from "react"; import { Textarea } from "@/components/ui/textarea"; -import { useForm } from "react-hook-form"; +import { useForm, SubmitHandler } from "react-hook-form"; import { Tooltip, TooltipContent, @@ -18,13 +18,12 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { DualOptionSelector } from "@/components/dualSelector"; import { MultipleOptionSelector } from "@/components/multipleSelector"; import BusinessForm from "@/components/BusinessForm"; +import { businessFormSchema } from "@/types/schemas/application.schema"; +type businessSchema = z.infer; export default function Apply() { + const form1 = useForm(); const [industry, setIndustry] = useState([]); - // const [isInUS, setIsInUS] = useState(""); - // const [isForSale, setIsForSale] = useState(""); - // const [isGenerating, setIsGenerating] = useState(""); - // const [businessPitch, setBusinessPitch] = useState("text"); const [projectType, setProjectType] = useState([]); const [projectPitch, setProjectPitch] = useState("text"); const [applyProject, setApplyProject] = useState(false); @@ -33,6 +32,18 @@ export default function Apply() { const [projectPitchFile, setProjectPitchFile] = useState(""); const MAX_FILE_SIZE = 5000000; const ACCEPTED_IMAGE_TYPES = ["image/jpeg", "image/jpg", "image/png"]; + + const handleSubmit: SubmitHandler = (data) => { + console.log("Submitted Data:", data); + // add api logic + }; + + const onSubmit: SubmitHandler = async (data) => { + // Your submit logic here + console.log(data); + // e.g. submit the data to an API + }; + const createPitchDeckSchema = (inputType: string) => { if (inputType === "text") { return z @@ -45,8 +56,7 @@ export default function Apply() { return z .custom( (val: any) => { - // confirm val is a File object - return val instanceof File; // Ensure it is a File instance + return val instanceof File; }, { message: "Input must be a file.", @@ -373,7 +383,7 @@ export default function Apply() { {/* form */} {/*
*/} - +
setApplyProject(!applyProject)}> @@ -705,7 +715,6 @@ export default function Apply() { Submit application - {/* */}
); } diff --git a/src/components/BusinessForm.tsx b/src/components/BusinessForm.tsx index 4ef9410..0610cf0 100644 --- a/src/components/BusinessForm.tsx +++ b/src/components/BusinessForm.tsx @@ -28,10 +28,9 @@ type businessSchema = z.infer; interface BusinessFormProps { industry: string[]; + handleSubmit: SubmitHandler; + onSubmit: () => void; } -const handleSubmit = (values: z.infer) => { - console.table(values); -}; const BusinessForm = ({ onSubmit, industry, @@ -49,29 +48,12 @@ const BusinessForm = ({ resolver: zodResolver(businessFormSchema), defaultValues: {}, }); - const [isInUS, setIsInUS] = useState(""); - const [isForSale, setIsForSale] = useState(""); - const [isGenerating, setIsGenerating] = useState(""); const [businessPitch, setBusinessPitch] = useState("text"); const [businessPitchFile, setBusinessPitchFile] = useState(""); - // const handleBusinessFieldChange = (fieldName: string, value: any) => { - // switch (fieldName) { - // case "isInUS": - // setIsInUS(value); - // break; - // case "isForSale": - // setIsForSale(value); - // break; - // case "isGenerating": - // setIsGenerating(value); - // break; - // } - // setValueBusiness(fieldName, value); - // }; return (
- +

About your company

@@ -170,7 +152,7 @@ const BusinessForm = ({ choice1="Yes" choice2="No" handleFunction={(selectedValues: string) => { - setIsInUS; + // setIsInUS; field.onChange(selectedValues); }} description={ @@ -204,7 +186,7 @@ const BusinessForm = ({ choice1="Yes" choice2="No" handleFunction={(selectedValues: string) => { - setIsForSale; + // setIsForSale; field.onChange(selectedValues); }} description={ @@ -235,7 +217,7 @@ const BusinessForm = ({ choice2="No" value={field.value} handleFunction={(selectedValues: string) => { - setIsGenerating; + // setIsGenerating; field.onChange(selectedValues); }} description={ @@ -284,16 +266,9 @@ const BusinessForm = ({ : "https:// " } accept={businessPitch === "file" ? ".md" : undefined} - // onChange={(e) => { - // if (businessPitch === "file") { - // setValueBusiness( - // "businessPitchDeck", - // e.target.files?.[0] || "" - // ); - // } else { - // field.onChange(e); - // } - // }} + onChange={(e) => { + field.onChange(e); + }} value={ businessPitch === "file" ? "" : (field.value as string) } @@ -304,7 +279,6 @@ const BusinessForm = ({