mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
fix: fix business ui loader not remove
This commit is contained in:
parent
e4cf116f30
commit
5c455d20ee
@ -72,6 +72,7 @@ const BusinessForm = ({ onSubmit }: BusinessFormProps & { onSubmit: SubmitHandle
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchCountries();
|
fetchCountries();
|
||||||
fetchIndustry();
|
fetchIndustry();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
@ -360,7 +361,7 @@ const BusinessForm = ({ onSubmit }: BusinessFormProps & { onSubmit: SubmitHandle
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<MultipleOptionSelector
|
<MultipleOptionSelector
|
||||||
header={<>What's the rough size of your community?</>}
|
header={<>What's the rough size of your community?</>}
|
||||||
fieldName="communitySize"
|
fieldName="communitySize"
|
||||||
choices={communitySize}
|
choices={communitySize}
|
||||||
handleFunction={(selectedValues: any) => {
|
handleFunction={(selectedValues: any) => {
|
||||||
@ -1,29 +1,28 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
import { useState, useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { SubmitHandler } from "react-hook-form";
|
import { SubmitHandler } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import BusinessForm from "@/components/BusinessForm";
|
import BusinessForm from "./BusinessForm";
|
||||||
import { businessFormSchema } from "@/types/schemas/application.schema";
|
import { businessFormSchema } from "@/types/schemas/application.schema";
|
||||||
import Swal from "sweetalert2";
|
import Swal from "sweetalert2";
|
||||||
import { getCurrentUserID } from "@/app/api/userApi";
|
import { getCurrentUserID } from "@/app/api/userApi";
|
||||||
import { uploadFile } from "@/app/api/generalApi";
|
import { uploadFile } from "@/app/api/generalApi";
|
||||||
import { Loader } from "@/components/loading/loader";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
type businessSchema = z.infer<typeof businessFormSchema>;
|
type businessSchema = z.infer<typeof businessFormSchema>;
|
||||||
const BUCKET_PITCH_NAME = "business-application";
|
const BUCKET_PITCH_NAME = "business-application";
|
||||||
let supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
|
|
||||||
export default function ApplyBusiness() {
|
export default function ApplyBusiness() {
|
||||||
|
const router = useRouter();
|
||||||
const alertShownRef = useRef(false);
|
const alertShownRef = useRef(false);
|
||||||
const [success, setSucess] = useState(false);
|
|
||||||
|
|
||||||
const onSubmit: SubmitHandler<businessSchema> = async (data) => {
|
const onSubmit: SubmitHandler<businessSchema> = async (data) => {
|
||||||
const transformedData = await transformChoice(data);
|
const transformedData = await transformChoice(data);
|
||||||
await sendApplication(transformedData);
|
await sendApplication(transformedData);
|
||||||
};
|
};
|
||||||
const sendApplication = async (recvData: any) => {
|
const sendApplication = async (recvData: any) => {
|
||||||
setSucess(false);
|
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { user },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getUser();
|
||||||
@ -65,7 +64,6 @@ export default function ApplyBusiness() {
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
.select();
|
.select();
|
||||||
setSucess(true);
|
|
||||||
// console.table(data);
|
// console.table(data);
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: error == null ? "success" : "error",
|
icon: error == null ? "success" : "error",
|
||||||
@ -73,7 +71,7 @@ export default function ApplyBusiness() {
|
|||||||
text: error == null ? "Your application has been submitted" : error.message,
|
text: error == null ? "Your application has been submitted" : error.message,
|
||||||
confirmButtonColor: error == null ? "green" : "red",
|
confirmButtonColor: error == null ? "green" : "red",
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
window.location.href = "/";
|
router.push("/");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,27 +113,24 @@ export default function ApplyBusiness() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchUserData = async () => {
|
const fetchUserData = async () => {
|
||||||
try {
|
try {
|
||||||
setSucess(false);
|
|
||||||
const userID = await getCurrentUserID();
|
const userID = await getCurrentUserID();
|
||||||
if (userID) {
|
if (userID) {
|
||||||
const hasApplied = await hasUserApplied(userID);
|
const hasApplied = await hasUserApplied(userID);
|
||||||
setSucess(true);
|
|
||||||
if (hasApplied && !alertShownRef.current) {
|
if (hasApplied && !alertShownRef.current) {
|
||||||
alertShownRef.current = true;
|
alertShownRef.current = true;
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: "info",
|
icon: "info",
|
||||||
title: "You Already Have an Account",
|
title: "You Already Have an Account or Application",
|
||||||
text: "You have already submitted your business application.",
|
text: "You have already submitted your business application.",
|
||||||
confirmButtonText: "OK",
|
confirmButtonText: "OK",
|
||||||
allowOutsideClick: false,
|
allowOutsideClick: false,
|
||||||
allowEscapeKey: false,
|
allowEscapeKey: false,
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
window.location.href = "/";
|
router.push("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setSucess(false);
|
|
||||||
} else {
|
} else {
|
||||||
console.error("User ID is undefined.");
|
console.error("User ID is undefined.");
|
||||||
}
|
}
|
||||||
@ -143,13 +138,12 @@ export default function ApplyBusiness() {
|
|||||||
console.error("Error fetching user ID:", error);
|
console.error("Error fetching user ID:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// setSucess(true);
|
|
||||||
fetchUserData();
|
fetchUserData();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Loader isSuccess={success} />
|
|
||||||
<div className="grid grid-flow-row auto-rows-max w-full h-52 md:h-92 bg-gray-100 dark:bg-gray-800 p-5">
|
<div className="grid grid-flow-row auto-rows-max w-full h-52 md:h-92 bg-gray-100 dark:bg-gray-800 p-5">
|
||||||
<h1 className="text-2xl md:text-5xl font-medium md:font-bold justify-self-center md:mt-8">
|
<h1 className="text-2xl md:text-5xl font-medium md:font-bold justify-self-center md:mt-8">
|
||||||
Apply to raise on B2DVentures
|
Apply to raise on B2DVentures
|
||||||
|
|||||||
22
src/components/loading/LegacyLoader.tsx
Normal file
22
src/components/loading/LegacyLoader.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
export function LegacyLoader() {
|
||||||
|
return (
|
||||||
|
<div className="container flex items-center justify-center h-screen">
|
||||||
|
<div className="text-center">
|
||||||
|
<svg
|
||||||
|
className="animate-spin h-12 w-12 text-gray-600 mx-auto mb-4"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
||||||
|
<path
|
||||||
|
className="opacity-75"
|
||||||
|
fill="currentColor"
|
||||||
|
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291l-2.832 2.832A10.003 10.003 0 0112 22v-4a8.001 8.001 0 01-6-5.709z"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
<p className="text-lg font-semibold text-gray-600">Loading data...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user