import { useEffect, useState } from "react"; import { SubmitHandler, useForm } from "react-hook-form"; import { Button } from "@/components/ui/button"; import { DualOptionSelector } from "@/components/dualSelector"; import { MultipleOptionSelector } from "@/components/multipleSelector"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { businessFormSchema } from "@/types/schemas/application.schema"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@radix-ui/react-tooltip"; type businessSchema = z.infer; interface BusinessFormProps { industry: {id: number, name:string}[]; applyProject: boolean; setApplyProject: Function; onSubmit: SubmitHandler; } const BusinessForm = ({ applyProject, setApplyProject, onSubmit, industry, }: BusinessFormProps & { onSubmit: SubmitHandler }) => { const communitySize = [ { id: 1, name: "N/A" }, { id: 2, name: "0-5K" }, { id: 3, name: "5-10K" }, { id: 4, name: "10-20K" }, { id: 5, name: "20-50K" }, { id: 6, name: "50-100K" }, { id: 7, name: "100K+" }, ]; const form = useForm({ resolver: zodResolver(businessFormSchema), defaultValues: {}, }); const [businessPitch, setBusinessPitch] = useState("text"); const [businessPitchFile, setBusinessPitchFile] = useState(""); const [countries, setCountries] = useState<{ id: number; name: string }[]>([]); useEffect(() => { const fetchCountries = async () => { try { const response = await fetch("https://restcountries.com/v3.1/all"); if (!response.ok) { throw new Error("Network response was not ok"); } const data = await response.json(); const countryList = data.map( (country: { name: { common: string } }, index: number) => ({ id: index + 1, name: country.name.common, }) ); setCountries(countryList.sort((a: { name: string; }, b: { name: any; }) => a.name.localeCompare(b.name))); } catch (error) { console.error("Error fetching countries:", error); } }; fetchCountries(); }, []); return (
)} className="space-y-8" >

About your company

**All requested information in this section is required.

{/* Company Name */} ( Company name
This should be the name your company uses on your{" "}
website and in the market.
)} /> {/* Country */} ( Country} fieldName="country" choices={countries} handleFunction={(selectedValues: any) => { // console.log("Country selected: " + selectedValues.name); field.onChange(selectedValues.name); }} description={ <>Select the country where your business is based. } placeholder="Select a country" selectLabel="Country" /> )} /> {/* Industry */} ( Industry} fieldName="industry" choices={industry} handleFunction={(selectedValues: any) => { // console.log("Type of selected value:", selectedValues.id); field.onChange(selectedValues.id); }} description={ <> Choose the industry that best aligns with your business. } placeholder="Select an industry" selectLabel="Industry" /> )} /> {/* Raised Money */} (
{ const value = e.target.value; field.onChange(value ? parseFloat(value) : null); }} value={field.value} /> The sum total of past financing, including angel or venture
capital, loans, grants, or token sales.
)} /> {/* Incorporated in US */} (
Is your company incorporated in the United States? } choice1="Yes" choice2="No" handleFunction={(selectedValues: string) => { // setIsInUS; field.onChange(selectedValues); }} description={<>} value={field.value} /> Only companies that are incorporated or formed in the US are eligible to raise via Reg CF.
)} /> {/* Product for Sale */} (
Is your product available (for sale) in market? } choice1="Yes" choice2="No" handleFunction={(selectedValues: string) => { // setIsForSale; field.onChange(selectedValues); }} description={ <> Only check this box if customers can access, use, or buy your product today. } />
)} /> {/* Generating Revenue */} (
Is your company generating revenue?} choice1="Yes" choice2="No" value={field.value} handleFunction={(selectedValues: string) => { field.onChange(selectedValues); }} description={ <> Only check this box if your company is making money. Please elaborate on revenue below. } />
)} /> {/* Pitch Deck */} (
{ const value = e.target; if (businessPitch === "file") { const file = value.files?.[0]; field.onChange(file || ""); } else { field.onChange(value.value); } }} className="w-96 mt-5" /> Your pitch deck and other application info will be used for
internal purposes only.
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

{businessPitchFile && (
1. {businessPitchFile}
)}
)} /> {/* Community Size */} ( What's the rough size of your community?} fieldName="communitySize" choices={communitySize} handleFunction={(selectedValues: any) => { field.onChange(selectedValues.name); }} description={ <> Include your email list, social media following (e.g., Instagram, Discord, Twitter). } placeholder="Select" selectLabel="Select" /> )} />
setApplyProject(!applyProject)} > Would you like to apply for your first fundraising project as well?

Toggling this option allows you to begin your first project,
which is crucial for unlocking the tools necessary to raise funds.

); }; export default BusinessForm;