Refactor projectFormSchema in application.schema.ts

This commit is contained in:
THIS ONE IS A LITTLE BIT TRICKY KRUB 2024-10-19 17:32:56 +07:00
parent d6c967f0b4
commit 0e25a210fe
3 changed files with 359 additions and 597 deletions

View File

@ -1,310 +1,26 @@
"use client"; "use client";
import { useState } from "react"; import { useState } from "react";
import { Button } from "@/components/ui/button"; import ProjectForm from "@/components/ProjectForm";
import { Input } from "@/components/ui/input"; import { projectFormSchema } from "@/types/schemas/application.schema";
import { Label } from "@/components/ui/label"; import { z } from "zod";
import { Textarea } from "@/components/ui/textarea"; import { SubmitHandler } from "react-hook-form";
type projectSchema = z.infer<typeof projectFormSchema>;
export default function ApplyProject() { export default function ApplyProject() {
const [projectType, setProjectType] = useState<string[]>([]); const [projectType, setProjectType] = useState<string[]>([]);
const [projectPitch, setProjectPitch] = useState("text"); const [projectPitch, setProjectPitch] = useState("text");
const [applyProject, setApplyProject] = useState(false); const [applyProject, setApplyProject] = useState(false);
const [selectedImages, setSelectedImages] = useState<File[]>([]); const [selectedImages, setSelectedImages] = useState<File[]>([]);
const [projectPitchFile, setProjectPitchFile] = useState(""); const [projectPitchFile, setProjectPitchFile] = useState("");
const onSubmit: SubmitHandler<projectSchema> = async (data) => {
alert("มาแน้ววว");
console.table(data);
};
return ( return (
<div> <div>
{" "}
<div className="grid auto-rows-max w-3/4 ml-48 bg-zinc-100 dark:bg-zinc-900 mt-10 pt-12 pb-12"> <div className="grid auto-rows-max w-3/4 ml-48 bg-zinc-100 dark:bg-zinc-900 mt-10 pt-12 pb-12">
{/* header */} <ProjectForm onSubmit={onSubmit} />
<div className="ml-[15%]">
<h1 className="text-3xl font-bold mt-10">
Begin Your First Fundraising Project
</h1>
<p className="mt-3 text-sm text-neutral-500">
Starting a fundraising project is mandatory for all businesses. This
step is crucial <br />
to begin your journey and unlock the necessary tools for raising
funds.
</p>
{/* project's name */}
<div className="mt-10 space-y-5">
<Label htmlFor="projectName" className="font-bold text-lg">
Project name
</Label>
<div className="flex space-x-5">
<Input
type="text"
id="projectName"
className="w-96"
{...registerSecondForm("projectName")}
/>
</div>
</div>
{errorsProject.projectName && (
<p className="text-red-500 text-sm">
{errorsProject.projectName.message as string}
</p>
)}
{/* project type */}
{/* <MultipleOptionSelector
header={<>Project type</>}
fieldName="projectType"
choices={projectType}
// handleFunction={handleProjectFieldChange}
description={<>Please specify the primary purpose of the funds</>}
placeholder="Select a Project type"
selectLabel="Project type"
/> */}
{errorsProject.projectType && (
<p className="text-red-500 text-sm">
{errorsProject.projectType.message as string}
</p>
)}
{/* short description */}
<div className="mt-10 space-y-5">
<Label htmlFor="shortDescription" className="font-bold text-lg">
Short description
</Label>
<div className="flex space-x-5">
<Textarea
id="shortDescription"
className="w-96"
{...registerSecondForm("shortDescription")}
/>
<span className="text-[12px] text-neutral-500 self-center">
Could you provide a brief description of your project <br /> in
one or two sentences?
</span>
</div>
</div>
{errorsProject.shortDescription && (
<p className="text-red-500 text-sm">
{errorsProject.shortDescription.message as string}
</p>
)}
{/* Pitch deck */}
<div className="mt-10 space-y-5">
<Label htmlFor="projectPitchDeck" className="font-bold text-lg">
Pitch deck
</Label>
<div className="flex space-x-2 w-96">
<Button
type="button"
variant={projectPitch === "text" ? "default" : "outline"}
onClick={() => setProjectPitch("text")}
className="w-32 h-12 text-base"
>
Paste URL
</Button>
<Button
type="button"
variant={projectPitch === "file" ? "default" : "outline"}
onClick={() => setProjectPitch("file")}
className="w-32 h-12 text-base"
>
Upload a file
</Button>
</div>
<div className="flex space-x-5">
<Input
type={projectPitch}
id="projectPitchDeck"
className="w-96"
placeholder={
projectPitch === "file"
? "Upload your Markdown file"
: "https:// "
}
accept={projectPitch === "file" ? ".md" : undefined}
{...(projectPitch === "text"
? registerSecondForm("projectPitchDeck", {
required: true,
})
: {
onChange: (e) => {
const file = e.target.files?.[0];
setValueProject("projectPitchDeck", file);
setProjectPitchFile(file?.name || "");
},
})}
/>
<span className="text-[12px] text-neutral-500 self-center">
Please upload a file or paste a link to your pitch, which should{" "}
<br />
cover key aspects of your project: what it will do, what
investors <br /> can expect to gain, and any highlights that
make it stand out.
</span>
</div>
{projectPitchFile && (
<div className="flex justify-between items-center border p-2 rounded w-96 text-sm text-foreground">
<span>1. {projectPitchFile}</span>
<Button
className="ml-4"
onClick={() => {
setValueProject("projectPitchDeck", "");
setProjectPitchFile("");
}}
>
Remove
</Button>
</div>
)}
</div>
{errorsProject.projectPitchDeck && (
<p className="text-red-500 text-sm">
{errorsProject.projectPitchDeck.message as string}
</p>
)}
{/* project logo */}
<div className="mt-10 space-y-5">
<Label htmlFor="projectLogo" className="font-bold text-lg mt-10">
Project logo
</Label>
<div className="flex space-x-5">
<Input
type="file"
id="projectLogo"
className="w-96"
accept="image/*"
onChange={(e) => {
const file = e.target.files?.[0];
registerSecondForm("projectLogo").onChange({
target: { name: "projectLogo", value: file },
});
}}
/>
<span className="text-[12px] text-neutral-500 self-center">
Please upload the logo picture that best represents your
project.
</span>
</div>
</div>
{errorsProject.projectLogo && (
<p className="text-red-500 text-sm">
{errorsProject.projectLogo.message as string}
</p>
)}
<div className="mt-10 space-y-5">
<Label htmlFor="projectPhotos" className="font-bold text-lg mt-10">
Project photos
</Label>
<div className="flex space-x-5">
<Input
type="file"
id="projectPhotos"
multiple
accept="image/*"
className="w-96"
{...registerSecondForm("projectPhotos", {
required: true,
onChange: handleFileChange,
})}
/>
<span className="text-[12px] text-neutral-500 self-center">
Feel free to upload any additional images that provide <br />
further insight into your project.
</span>
</div>
<div className="mt-5 space-y-2 w-96">
{selectedImages.map((image, index) => (
<div
key={index}
className="flex justify-between items-center border p-2 rounded"
>
<span>{image.name}</span>
<Button
variant="outline"
onClick={() => handleRemoveImage(index)}
className="ml-4"
type="reset"
>
Remove
</Button>
</div>
))}
</div>
</div>
{errorsProject.projectPhotos && (
<p className="text-red-500 text-sm">
{errorsProject.projectPhotos.message as string}
</p>
)}
{/* Minimum Investment */}
<div className="space-y-5 mt-10">
<Label htmlFor="minInvest" className="font-bold text-lg">
Minimum investment
</Label>
<div className="flex space-x-5">
<Input
type="number"
id="minInvest"
className="w-96"
placeholder="$ 500"
{...registerSecondForm("minInvest", {
valueAsNumber: true,
})}
/>
<span className="text-[12px] text-neutral-500 self-center">
This helps set clear expectations for investors
</span>
</div>
</div>
{errorsProject.minInvest && (
<p className="text-red-500 text-sm">
{errorsProject.minInvest.message as string}
</p>
)}
{/* Target Investment */}
<div className="space-y-5 mt-10">
<Label htmlFor="targetInvest" className="font-bold text-lg">
Target investment
</Label>
<div className="flex space-x-5">
<Input
type="number"
id="targetInvest"
className="w-96"
placeholder="$ 1,000,000"
{...registerSecondForm("targetInvest", {
valueAsNumber: true,
})}
/>
<span className="text-[12px] text-neutral-500 self-center">
We encourage you to set a specific target investment <br />{" "}
amount that reflects your funding goals.
</span>
</div>
</div>
{errorsProject.targetInvest && (
<p className="text-red-500 text-sm">
{errorsProject.targetInvest.message as string}
</p>
)}
{/* Deadline */}
<div className="space-y-5 mt-10">
<Label htmlFor="deadline" className="font-bold text-lg">
Deadline
</Label>
<div className="flex space-x-5">
<Input
type="datetime-local"
id="deadline"
className="w-96"
{...registerSecondForm("deadline")}
/>
<span className="text-[12px] text-neutral-500 self-center">
What is the deadline for your fundraising project? Setting{" "}
<br /> a clear timeline can help motivate potential investors.
</span>
</div>
</div>
{errorsProject.deadline && (
<p className="text-red-500 text-sm">
{errorsProject.deadline.message as string}
</p>
)}
</div>
</div> </div>
</div> </div>
); );

View File

@ -1,7 +1,6 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { SubmitHandler, useForm } from "react-hook-form"; import { SubmitHandler, useForm, ControllerRenderProps } from "react-hook-form";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { DualOptionSelector } from "@/components/dualSelector";
import { MultipleOptionSelector } from "@/components/multipleSelector"; import { MultipleOptionSelector } from "@/components/multipleSelector";
import { import {
Form, Form,
@ -16,17 +15,11 @@ import { projectFormSchema } from "@/types/schemas/application.schema";
import { z } from "zod"; import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@radix-ui/react-tooltip";
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
import { Textarea } from "./ui/textarea"; import { Textarea } from "./ui/textarea";
type projectSchema = z.infer<typeof projectFormSchema>; type projectSchema = z.infer<typeof projectFormSchema>;
type FieldType = ControllerRenderProps<any, "projectPhotos">;
interface ProjectFormProps { interface ProjectFormProps {
onSubmit: SubmitHandler<projectSchema>; onSubmit: SubmitHandler<projectSchema>;
@ -43,26 +36,31 @@ const ProjectForm = ({
{ id: number; name: string }[] { id: number; name: string }[]
>([]); >([]);
const [projectPitch, setProjectPitch] = useState("text"); const [projectPitch, setProjectPitch] = useState("text");
const [applyProject, setApplyProject] = useState(false);
const [selectedImages, setSelectedImages] = useState<File[]>([]); const [selectedImages, setSelectedImages] = useState<File[]>([]);
const [projectPitchFile, setProjectPitchFile] = useState(""); const [projectPitchFile, setProjectPitchFile] = useState("");
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleFileChange = (
event: React.ChangeEvent<HTMLInputElement>,
field: FieldType
) => {
if (event.target.files) { if (event.target.files) {
const filesArray = Array.from(event.target.files); const filesArray = Array.from(event.target.files);
console.log("first file", filesArray); console.log("first file", filesArray);
setSelectedImages((prevImages) => { setSelectedImages((prevImages) => {
const updatedImages = [...prevImages, ...filesArray]; const updatedImages = [...prevImages, ...filesArray];
console.log("Updated Images Array:", updatedImages); console.log("Updated Images Array:", updatedImages);
field.onChange(updatedImages);
return updatedImages; return updatedImages;
}); });
} }
}; };
const handleRemoveImage = (index: number) => { const handleRemoveImage = (index: number, field: FieldType) => {
setSelectedImages((prevImages) => { setSelectedImages((prevImages) => {
const updatedImages = prevImages.filter((_, i) => i !== index); const updatedImages = prevImages.filter((_, i) => i !== index);
console.log("After removal - Updated Images:", updatedImages); console.log("After removal - Updated Images:", updatedImages);
field.onChange(updatedImages);
return updatedImages; return updatedImages;
}); });
}; };
@ -86,7 +84,7 @@ const ProjectForm = ({
} }
}; };
useEffect(() => { useEffect(() => {
fetchProjectType; fetchProjectType();
}, []); }, []);
return ( return (
<Form {...form}> <Form {...form}>
@ -94,200 +92,232 @@ const ProjectForm = ({
onSubmit={form.handleSubmit(onSubmit as SubmitHandler<projectSchema>)} onSubmit={form.handleSubmit(onSubmit as SubmitHandler<projectSchema>)}
className="space-y-8" className="space-y-8"
> >
<div className="ml-[15%]"> <h1 className="text-3xl font-bold mt-10">
<h1 className="text-3xl font-bold mt-10"> Begin Your First Fundraising Project
Begin Your First Fundraising Project </h1>
</h1> <p className="mt-3 text-sm text-neutral-500">
<p className="mt-3 text-sm text-neutral-500"> Starting a fundraising project is mandatory for all businesses. This
Starting a fundraising project is mandatory for all businesses. This step is crucial <br />
step is crucial <br /> to begin your journey and unlock the necessary tools for raising
to begin your journey and unlock the necessary tools for raising funds.
funds. </p>
</p> <div className="ml-96 mt-5 space-y-10">
<div className="ml-96 mt-5 space-y-10"> {/* project name */}
{/* project name */} <FormField
<FormField control={form.control}
control={form.control} name="projectName"
name="projectName" render={({ field }: { field: any }) => (
render={({ field }: { field: any }) => ( <FormItem>
<FormItem> <div className="mt-10 space-y-5">
<FormLabel className="font-bold text-lg">
Project name
</FormLabel>
<FormControl>
<div className="flex space-x-5">
<Input
type="text"
id="projectName"
className="w-96"
{...field}
/>
</div>
</FormControl>
</div>
<FormMessage />
</FormItem>
)}
/>
{/* project type */}
<FormField
control={form.control}
name="projectType"
render={({ field }: { field: any }) => (
<FormItem>
<FormControl>
<MultipleOptionSelector
header={<>Project type</>}
fieldName="projectType"
choices={projectType}
handleFunction={(selectedValues: any) => {
field.onChange(selectedValues.name);
}}
description={
<>Please specify the primary purpose of the funds</>
}
placeholder="Select a Project type"
selectLabel="Project type"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* short description */}
<FormField
control={form.control}
name="shortDescription"
render={({ field }: { field: any }) => (
<FormItem>
<FormControl>
<div className="mt-10 space-y-5"> <div className="mt-10 space-y-5">
<FormLabel className="font-bold text-lg"> <FormLabel className="font-bold text-lg">
Project name Short description
</FormLabel> </FormLabel>
<FormControl> <div className="flex space-x-5">
<Textarea
id="shortDescription"
className="w-96"
{...field}
/>
<span className="text-[12px] text-neutral-500 self-center">
Could you provide a brief description of your project{" "}
<br /> in one or two sentences?
</span>
</div>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* Pitch Deck */}
<FormField
control={form.control}
name="projectPitchDeck"
render={({ field }) => (
<FormItem>
<div className="space-y-5 mt-10">
<Label htmlFor="pitchDeck" className="font-bold text-lg">
Pitch deck
</Label>
<FormControl>
<div>
<div className="flex space-x-2 w-96">
<Button
type="button"
variant={
projectPitch === "text" ? "default" : "outline"
}
onClick={() => setProjectPitch("text")}
className="w-32 h-12 text-base"
>
Paste URL
</Button>
<Button
type="button"
variant={
projectPitch === "file" ? "default" : "outline"
}
onClick={() => setProjectPitch("file")}
className="w-32 h-12 text-base"
>
Upload a file
</Button>
</div>
<div className="flex space-x-5"> <div className="flex space-x-5">
<Input <Input
type="text" type={projectPitch === "file" ? "file" : "text"}
id="projectName" placeholder={
className="w-96" projectPitch === "file"
{...field} ? "Upload your Markdown file"
: "https:// "
}
accept={projectPitch === "file" ? ".md" : undefined}
onChange={(e) => {
const value = e.target;
if (projectPitch === "file") {
const file = value.files?.[0];
field.onChange(file || "");
} else {
field.onChange(value.value);
}
}}
className="w-96 mt-5"
/> />
</div>
</FormControl>
</div>
<FormMessage />
</FormItem>
)}
/>
{/* project type */}
<FormField
control={form.control}
name="projectType"
render={({ field }: { field: any }) => (
<FormItem>
<FormControl>
<MultipleOptionSelector
header={<>Project type</>}
fieldName="projectType"
choices={projectType}
handleFunction={(selectedValues: any) => {
field.onChange(selectedValues.name);
}}
description={
<>Please specify the primary purpose of the funds</>
}
placeholder="Select a Project type"
selectLabel="Project type"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* short description */}
<FormField
control={form.control}
name="shortDescription"
render={({ field }: { field: any }) => (
<FormItem>
<FormControl>
<div className="mt-10 space-y-5">
<FormLabel className="font-bold text-lg">
Short description
</FormLabel>
<div className="flex space-x-5">
<Textarea
id="shortDescription"
className="w-96"
{...field}
/>
<span className="text-[12px] text-neutral-500 self-center"> <span className="text-[12px] text-neutral-500 self-center">
Could you provide a brief description of your project{" "} Please upload a file or paste a link to your pitch,
<br /> in one or two sentences? which should <br />
cover key aspects of your project: what it will do,
what investors <br /> can expect to gain, and any
highlights that make it stand out.
</span> </span>
</div> </div>
{projectPitchFile && (
<div className="flex justify-between items-center border p-2 rounded w-96 text-sm text-foreground">
<span>1. {projectPitchFile}</span>
<Button
className="ml-4"
onClick={() => {
setProjectPitchFile("");
}}
>
Remove
</Button>
</div>
)}
</div> </div>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </div>
)} </FormItem>
/> )}
/>
{/* Pitch Deck */} {/* project logo */}
<FormField <FormField
control={form.control} control={form.control}
name="projectPitchDeck" name="projectLogo"
render={({ field }) => ( render={({ field }: { field: any }) => (
<FormItem> <FormItem>
<div className="space-y-5 mt-10"> <FormControl>
<Label htmlFor="pitchDeck" className="font-bold text-lg"> <div className="mt-10 space-y-5">
Pitch deck <FormLabel className="font-bold text-lg mt-10">
</Label> Project logo
<FormControl> </FormLabel>
<div> <Input
<div className="flex space-x-2 w-96"> type="file"
<Button id="projectLogo"
type="button" className="w-96"
variant={ accept="image/*"
projectPitch === "text" ? "default" : "outline" onChange={(e) => {
} const file = e.target.files?.[0];
onClick={() => setProjectPitch("text")} field.onChange(file || "");
className="w-32 h-12 text-base" }}
> />
Paste URL <span className="text-[12px] text-neutral-500 self-center">
</Button> Please upload the logo picture that best represents your
<Button project.
type="button" </span>
variant={
projectPitch === "file" ? "default" : "outline"
}
onClick={() => setProjectPitch("file")}
className="w-32 h-12 text-base"
>
Upload a file
</Button>
</div>
<div className="flex space-x-5">
<Input
type={projectPitch === "file" ? "file" : "text"}
placeholder={
projectPitch === "file"
? "Upload your Markdown file"
: "https:// "
}
accept={projectPitch === "file" ? ".md" : undefined}
onChange={(e) => {
const value = e.target;
if (projectPitch === "file") {
const file = value.files?.[0];
field.onChange(file || "");
} else {
field.onChange(value.value);
}
}}
className="w-96 mt-5"
/>
<span className="text-[12px] text-neutral-500 self-center">
Please upload a file or paste a link to your pitch,
which should <br />
cover key aspects of your project: what it will do,
what investors <br /> can expect to gain, and any
highlights that make it stand out.
</span>
</div>
{projectPitchFile && (
<div className="flex justify-between items-center border p-2 rounded w-96 text-sm text-foreground">
<span>1. {projectPitchFile}</span>
<Button
className="ml-4"
onClick={() => {
setProjectPitchFile("");
}}
>
Remove
</Button>
</div>
)}
</div>
</FormControl>
<FormMessage />
</div> </div>
</FormItem> </FormControl>
)} <FormMessage />
/> </FormItem>
)}
/>
{/* project logo */} {/* project photos */}
<FormField <FormField
control={form.control} control={form.control}
name="projectLogo" name="projectPhotos"
render={({ field }: { field: any }) => ( render={({ field }: { field: any }) => (
<FormItem> <FormItem>
<FormControl> <FormControl>
<div className="mt-10 space-y-5"> <div className="mt-10 space-y-5">
<FormLabel className="font-bold text-lg mt-10"> <FormLabel className="font-bold text-lg mt-10">
Project logo Project photos
</FormLabel> </FormLabel>
<div className="flex space-x-5">
<Input <Input
type="file" type="file"
id="projectLogo" id="projectPhotos"
className="w-96" multiple
accept="image/*" accept="image/*"
onChange={(e) => { className="w-96"
const file = e.target.files?.[0]; onChange={(event) => {
field.onChange(file || ""); handleFileChange(event, field);
}} }}
/> />
<span className="text-[12px] text-neutral-500 self-center"> <span className="text-[12px] text-neutral-500 self-center">
@ -295,121 +325,136 @@ const ProjectForm = ({
project. project.
</span> </span>
</div> </div>
</FormControl> <div className="mt-5 space-y-2 w-96">
<FormMessage /> {selectedImages.map((image, index) => (
</FormItem> <div
)} key={index}
/> className="flex justify-between items-center border p-2 rounded"
>
{/* project photos */} <span>{image.name}</span>
<FormField <Button
control={form.control} variant="outline"
name="projectPhotos" onClick={() => handleRemoveImage(index, field)}
render={({ field }: { field: any }) => ( className="ml-4"
<FormItem> type="reset"
<FormControl>
<div className="mt-10 space-y-5">
<FormLabel className="font-bold text-lg mt-10">
Project photos
</FormLabel>
<div className="flex space-x-5">
<Input
type="file"
id="projectPhotos"
multiple
accept="image/*"
className="w-96"
onChange={handleFileChange}
/>
<span className="text-[12px] text-neutral-500 self-center">
Please upload the logo picture that best represents
your project.
</span>
</div>
<div className="mt-5 space-y-2 w-96">
{selectedImages.map((image, index) => (
<div
key={index}
className="flex justify-between items-center border p-2 rounded"
> >
<span>{image.name}</span> Remove
<Button </Button>
variant="outline" </div>
onClick={() => handleRemoveImage(index)} ))}
className="ml-4" </div>
type="reset" </div>
> </FormControl>
Remove <FormMessage />
</Button> </FormItem>
</div> )}
))} />
</div>
{/* Minimum investment */}
<FormField
control={form.control}
name="minInvest"
render={({ field }: { field: any }) => (
<FormItem>
<div className="mt-10 space-y-5">
<FormLabel className="font-bold text-lg">
Minimum investment
</FormLabel>
<FormControl>
<div className="flex space-x-5">
<Input
type="number"
id="minInvest"
placeholder="$ 500"
className="w-96"
{...field}
onChange={(e) => {
const value = e.target.value;
field.onChange(value ? parseFloat(value) : null);
}}
value={field.value}
/>
<span className="text-[12px] text-neutral-500 self-center">
This helps set clear expectations for investors
</span>
</div> </div>
</FormControl> </FormControl>
<FormMessage /> </div>
</FormItem> <FormMessage />
)} </FormItem>
/> )}
/>
{/* Community Size */} {/* Target investment */}
<FormField <FormField
control={form.control} control={form.control}
name="communitySize" name="targetInvest"
render={({ field }) => ( render={({ field }: { field: any }) => (
<FormItem> <FormItem>
<div className="mt-10 space-y-5">
<FormLabel className="font-bold text-lg">
Target investment
</FormLabel>
<FormControl> <FormControl>
<MultipleOptionSelector <div className="flex space-x-5">
header={<>What's the rough size of your community?</>} <Input
fieldName="communitySize" type="number"
choices={communitySize} id="targetInvest"
handleFunction={(selectedValues: any) => { className="w-96"
field.onChange(selectedValues.name); placeholder="$ 1,000,000"
}} {...field}
description={ onChange={(e) => {
<> const value = e.target.value;
Include your email list, social media following (e.g., field.onChange(value ? parseFloat(value) : null);
Instagram, Discord, Twitter). }}
</> value={field.value}
} />
placeholder="Select" <span className="text-[12px] text-neutral-500 self-center">
selectLabel="Select" We encourage you to set a specific target investment{" "}
/> <br /> amount that reflects your funding goals.
</span>
</div>
</FormControl> </FormControl>
<FormMessage /> </div>
</FormItem> <FormMessage />
)} </FormItem>
/> )}
<div className="flex space-x-5"> />
<Switch {/* Deadline */}
onCheckedChange={() => setApplyProject(!applyProject)} <FormField
></Switch> control={form.control}
<TooltipProvider> name="deadline"
<Tooltip> render={({ field }: { field: any }) => (
<TooltipTrigger asChild> <FormItem>
<span className="text-[12px] text-neutral-500 self-center cursor-pointer"> <div className="mt-10 space-y-5">
Would you like to apply for your first fundraising project <FormLabel className="font-bold text-lg">Deadline</FormLabel>
as well? <FormControl>
</span> <div className="flex space-x-5">
</TooltipTrigger> <Input
<TooltipContent> type="datetime-local"
<p className="text-[11px]"> id="deadline"
Toggling this option allows you to begin your first className="w-96"
project, <br /> which is crucial for unlocking the tools {...field}
necessary to raise funds. />
</p> <span className="text-[12px] text-neutral-500 self-center">
</TooltipContent> What is the deadline for your fundraising project?
</Tooltip> Setting <br /> a clear timeline can help motivate
</TooltipProvider> potential investors.
</div> </span>
<center> </div>
<Button </FormControl>
className="mt-12 mb-20 h-10 text-base font-bold py-6 px-5" </div>
type="submit" <FormMessage />
> </FormItem>
Submit application )}
</Button> />
</center> <center>
</div> <Button
className="mt-12 mb-20 h-10 text-base font-bold py-6 px-5"
type="submit"
>
Submit application
</Button>
</center>
</div> </div>
</form> </form>
</Form> </Form>

View File

@ -53,10 +53,10 @@ const projectFormSchema = z.object({
projectPhotos: z.custom( projectPhotos: z.custom(
(value) => { (value) => {
if (value instanceof FileList || Array.isArray(value)) { if (value instanceof FileList || Array.isArray(value)) {
if (value.length === 1) { return (
return false; value.length > 0 &&
} Array.from(value).every((item) => item instanceof File)
return Array.from(value).every((item) => item instanceof File); );
} }
return false; return false;
}, },
@ -65,6 +65,7 @@ const projectFormSchema = z.object({
"Must be a FileList or an array of File objects with at least one file.", "Must be a FileList or an array of File objects with at least one file.",
} }
), ),
minInvest: z minInvest: z
.number({ .number({
required_error: "Minimum investment must be a number.", required_error: "Minimum investment must be a number.",