mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-20 14:34:05 +01:00
Refactor ApplyBusiness component and BusinessForm component
This commit is contained in:
parent
2fba56288d
commit
ca895bd605
@ -15,7 +15,6 @@ const BUCKET_PITCH_NAME = "business-application";
|
|||||||
let supabase = createSupabaseClient();
|
let supabase = createSupabaseClient();
|
||||||
|
|
||||||
export default function ApplyBusiness() {
|
export default function ApplyBusiness() {
|
||||||
const [applyProject, setApplyProject] = useState(false);
|
|
||||||
const alertShownRef = useRef(false);
|
const alertShownRef = useRef(false);
|
||||||
const [success, setSucess] = useState(false);
|
const [success, setSucess] = useState(false);
|
||||||
|
|
||||||
@ -75,12 +74,8 @@ export default function ApplyBusiness() {
|
|||||||
text:
|
text:
|
||||||
error == null ? "Your application has been submitted" : error.message,
|
error == null ? "Your application has been submitted" : error.message,
|
||||||
confirmButtonColor: error == null ? "green" : "red",
|
confirmButtonColor: error == null ? "green" : "red",
|
||||||
}).then((result) => {
|
}).then(() => {
|
||||||
if (result.isConfirmed && applyProject) {
|
|
||||||
window.location.href = "/project/apply";
|
|
||||||
} else {
|
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,7 +93,10 @@ export default function ApplyBusiness() {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
console.error(applicationError);
|
console.error(applicationError);
|
||||||
}
|
}
|
||||||
if ((business && business.length != 0) || (businessApplication && businessApplication.length != 0)) {
|
if (
|
||||||
|
(business && business.length != 0) ||
|
||||||
|
(businessApplication && businessApplication.length != 0)
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -156,8 +154,8 @@ export default function ApplyBusiness() {
|
|||||||
console.error("Error fetching user ID:", error);
|
console.error("Error fetching user ID:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// setSucess(true);
|
setSucess(true);
|
||||||
fetchUserData();
|
// fetchUserData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -180,11 +178,7 @@ export default function ApplyBusiness() {
|
|||||||
</div>
|
</div>
|
||||||
{/* form */}
|
{/* form */}
|
||||||
{/* <form action="" onSubmit={handleSubmit(handleSubmitForms)}> */}
|
{/* <form action="" onSubmit={handleSubmit(handleSubmitForms)}> */}
|
||||||
<BusinessForm
|
<BusinessForm onSubmit={onSubmit} />
|
||||||
onSubmit={onSubmit}
|
|
||||||
applyProject={applyProject}
|
|
||||||
setApplyProject={setApplyProject}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,25 +17,14 @@ import { businessFormSchema } 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";
|
||||||
|
|
||||||
type businessSchema = z.infer<typeof businessFormSchema>;
|
type businessSchema = z.infer<typeof businessFormSchema>;
|
||||||
|
|
||||||
interface BusinessFormProps {
|
interface BusinessFormProps {
|
||||||
applyProject: boolean;
|
|
||||||
setApplyProject: Function;
|
|
||||||
onSubmit: SubmitHandler<businessSchema>;
|
onSubmit: SubmitHandler<businessSchema>;
|
||||||
}
|
}
|
||||||
const BusinessForm = ({
|
const BusinessForm = ({
|
||||||
applyProject,
|
|
||||||
setApplyProject,
|
|
||||||
onSubmit,
|
onSubmit,
|
||||||
}: BusinessFormProps & { onSubmit: SubmitHandler<businessSchema> }) => {
|
}: BusinessFormProps & { onSubmit: SubmitHandler<businessSchema> }) => {
|
||||||
const communitySize = [
|
const communitySize = [
|
||||||
@ -461,28 +450,6 @@ const BusinessForm = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<div className="flex space-x-5">
|
|
||||||
<Switch
|
|
||||||
onCheckedChange={() => setApplyProject(!applyProject)}
|
|
||||||
></Switch>
|
|
||||||
<TooltipProvider>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<span className="text-[12px] text-neutral-500 self-center cursor-pointer">
|
|
||||||
Would you like to apply for your first fundraising project
|
|
||||||
as well?
|
|
||||||
</span>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
<p className="text-[11px]">
|
|
||||||
Toggling this option allows you to begin your first
|
|
||||||
project, <br /> which is crucial for unlocking the tools
|
|
||||||
necessary to raise funds.
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</TooltipProvider>
|
|
||||||
</div>
|
|
||||||
<center>
|
<center>
|
||||||
<Button
|
<Button
|
||||||
className="mt-12 mb-20 h-10 text-base font-bold py-6 px-5"
|
className="mt-12 mb-20 h-10 text-base font-bold py-6 px-5"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user