From d6c967f0b44681c979aafee71fa7a1ea9a0fc9ea Mon Sep 17 00:00:00 2001 From: THIS ONE IS A LITTLE BIT TRICKY KRUB Date: Sat, 19 Oct 2024 16:57:06 +0700 Subject: [PATCH] Refactor ProjectForm --- src/components/ProjectForm.tsx | 306 ++++++++++++++------------------- 1 file changed, 131 insertions(+), 175 deletions(-) diff --git a/src/components/ProjectForm.tsx b/src/components/ProjectForm.tsx index 51d0da3..8b09cbe 100644 --- a/src/components/ProjectForm.tsx +++ b/src/components/ProjectForm.tsx @@ -6,7 +6,6 @@ import { MultipleOptionSelector } from "@/components/multipleSelector"; import { Form, FormControl, - FormDescription, FormField, FormItem, FormLabel, @@ -25,13 +24,14 @@ import { TooltipTrigger, } from "@radix-ui/react-tooltip"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; +import { Textarea } from "./ui/textarea"; type projectSchema = z.infer; interface ProjectFormProps { onSubmit: SubmitHandler; } -const BusinessForm = ({ +const ProjectForm = ({ onSubmit, }: ProjectFormProps & { onSubmit: SubmitHandler }) => { const form = useForm({ @@ -47,6 +47,26 @@ const BusinessForm = ({ const [selectedImages, setSelectedImages] = useState([]); const [projectPitchFile, setProjectPitchFile] = useState(""); + const handleFileChange = (event: React.ChangeEvent) => { + if (event.target.files) { + const filesArray = Array.from(event.target.files); + console.log("first file", filesArray); + setSelectedImages((prevImages) => { + const updatedImages = [...prevImages, ...filesArray]; + console.log("Updated Images Array:", updatedImages); + return updatedImages; + }); + } + }; + + const handleRemoveImage = (index: number) => { + setSelectedImages((prevImages) => { + const updatedImages = prevImages.filter((_, i) => i !== index); + console.log("After removal - Updated Images:", updatedImages); + return updatedImages; + }); + }; + const fetchProjectType = async () => { let { data: ProjectType, error } = await supabase .from("project_type") @@ -139,163 +159,25 @@ const BusinessForm = ({ {/* short description */} ( - 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 */} - ( - -
- - +
+ + Short description +
- { - 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. + Could you provide a brief description of your project{" "} +
in one or two sentences?
- - -
- - )} - /> - - {/* 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. - - } - />
@@ -306,7 +188,7 @@ const BusinessForm = ({ {/* Pitch Deck */} (
@@ -319,9 +201,9 @@ const BusinessForm = ({
{ const value = e.target; - if (businessPitch === "file") { + if (projectPitch === "file") { const file = value.files?.[0]; field.onChange(file || ""); } else { @@ -361,26 +241,20 @@ const BusinessForm = ({ /> - 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 -

+ Please upload a file or paste a link to your pitch, + which should
+ cover key aspects of your project: what it will do, + what investors
can expect to gain, and any + highlights that make it stand out.
- {businessPitchFile && ( + {projectPitchFile && (
- 1. {businessPitchFile} + 1. {projectPitchFile} +
+ ))} +
+ + + +
+ )} + /> + {/* Community Size */}