From 3370b0f61cababdccbc2495ab56f2799f40f7b25 Mon Sep 17 00:00:00 2001
From: THIS ONE IS A LITTLE BIT TRICKY KRUB
Date: Sun, 13 Oct 2024 16:34:30 +0700
Subject: [PATCH] Refactor Apply page component to adjust left margin for
company information section
---
src/app/business/apply/page.tsx | 500 ++++++++++++++++----------------
1 file changed, 253 insertions(+), 247 deletions(-)
diff --git a/src/app/business/apply/page.tsx b/src/app/business/apply/page.tsx
index 17d4145..206916d 100644
--- a/src/app/business/apply/page.tsx
+++ b/src/app/business/apply/page.tsx
@@ -32,8 +32,8 @@ export default function Apply() {
z.string().url("Pitch deck must be a valid URL."),
z.object({}),
]);
-
- const formSchema = z.object({
+ const projectFormSchema = z.object({});
+ const businessFormSchema = z.object({
companyName: z.string().min(5, {
message: "Company name must be at least 5 characters.",
}),
@@ -78,12 +78,21 @@ export default function Apply() {
});
let supabase = createSupabaseClient();
const {
- register,
- handleSubmit,
- setValue,
- formState: { errors },
+ register: registerBusiness,
+ handleSubmit: handleSubmitBusiness,
+ setValue: setValueBusiness,
+ formState: { errors: errorsBusiness },
} = useForm({
- resolver: zodResolver(formSchema),
+ resolver: zodResolver(businessFormSchema),
+ });
+
+ const {
+ register: registerProject,
+ handleSubmit: handleSubmitProject,
+ setValue: setValueProject,
+ formState: { errors: errorsProject },
+ } = useForm({
+ resolver: zodResolver(projectFormSchema),
});
const [industry, setIndustry] = useState([]);
const [isInUS, setIsInUS] = useState("");
@@ -106,11 +115,11 @@ export default function Apply() {
];
useEffect(() => {
- register("industry");
- register("isInUS");
- register("isForSale");
- register("isGenerating");
- }, [register]);
+ registerBusiness("industry");
+ registerBusiness("isInUS");
+ registerBusiness("isForSale");
+ registerBusiness("isGenerating");
+ }, [registerBusiness]);
const handleRemoveImage = (index: number) => {
const updatedImages = selectedImages.filter((_, i) => i !== index);
@@ -155,7 +164,7 @@ export default function Apply() {
const handleBusinessPitchChange = (type: string) => {
setBusinessPitch(type);
// clear out old data
- setValue("pitchDeck", "");
+ setValueBusiness("pitchDeck", "");
};
const handleFieldChange = (fieldName: string, value: any) => {
@@ -170,7 +179,7 @@ export default function Apply() {
setIsGenerating(value);
break;
}
- setValue(fieldName, value);
+ setValueBusiness(fieldName, value);
};
const fetchIndustry = async () => {
let { data: BusinessType, error } = await supabase
@@ -222,7 +231,7 @@ export default function Apply() {
{/* form */}
-
@@ -271,9 +280,9 @@ export default function Apply() {
placeholder="Select an industry"
selectLabel="Industry"
/>
- {errors.industry && (
+ {errorsBusiness.industry && (
- {errors.industry.message as string}
+ {errorsBusiness.industry.message as string}
)}
{/* How much money has your company raised to date? */}
@@ -287,7 +296,7 @@ export default function Apply() {
id="totalRaised"
className="w-96"
placeholder="$ 1,000,000"
- {...register("totalRaised", {
+ {...registerBusiness("totalRaised", {
valueAsNumber: true,
})}
/>
@@ -297,9 +306,9 @@ export default function Apply() {
capital, loans, grants, or token sales.
- {errors.totalRaised && (
+ {errorsBusiness.totalRaised && (
- {errors.totalRaised.message as string}
+ {errorsBusiness.totalRaised.message as string}
)}
@@ -326,9 +335,9 @@ export default function Apply() {
}
value={isInUS}
/>
- {errors.isInUS && (
+ {errorsBusiness.isInUS && (
- {errors.isInUS.message as string}
+ {errorsBusiness.isInUS.message as string}
)}
@@ -353,9 +362,9 @@ export default function Apply() {
}
value={isForSale}
/>
- {errors.isForSale && (
+ {errorsBusiness.isForSale && (
- {errors.isForSale.message as string}
+ {errorsBusiness.isForSale.message as string}
)}
@@ -374,9 +383,9 @@ export default function Apply() {
}
value={isGenerating}
/>
- {errors.isGenerating && (
+ {errorsBusiness.isGenerating && (
- {errors.isGenerating.message as string}
+ {errorsBusiness.isGenerating.message as string}
)}
{/* Pitch deck */}
@@ -413,7 +422,7 @@ export default function Apply() {
: "https:// "
}
accept={businessPitch === "file" ? ".md" : undefined}
- {...register("pitchDeck", { required: true })}
+ {...registerBusiness("pitchDeck", { required: true })}
/>
@@ -423,12 +432,16 @@ export default function Apply() {
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
+
- {errors.pitchDeck && (
+ {errorsBusiness.pitchDeck && (
- {errors.pitchDeck.message as string}
+ {errorsBusiness.pitchDeck.message as string}
)}
- {errors.communitySize && (
+ {errorsBusiness.communitySize && (
- {errors.communitySize.message as string}
+ {errorsBusiness.communitySize.message as string}
)}
@@ -486,233 +499,226 @@ export default function Apply() {
{/* apply first project */}
{applyProject && (
- {/* header */}
-
-
- Begin Your First Fundraising Project
-
-
- Starting a fundraising project is mandatory for all businesses.
- This step is crucial
- to begin your journey and unlock the necessary tools for raising
- funds.
-
+