mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 21:44:06 +01:00
refactor: use useRouter instead of access window in DOM
This commit is contained in:
parent
73d5995d5b
commit
01dbb3588b
@ -1,3 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { SubmitHandler, useForm } from "react-hook-form";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
@ -10,12 +10,13 @@ import { getCurrentUserID } from "@/app/api/userApi";
|
||||
import { uploadFile } from "@/app/api/generalApi";
|
||||
import { Loader } from "@/components/loading/loader";
|
||||
import { hasUserApplied, transformChoice } from "./actions";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
type businessSchema = z.infer<typeof businessFormSchema>;
|
||||
const BUCKET_PITCH_NAME = "business-application";
|
||||
let supabase = createSupabaseClient();
|
||||
|
||||
export default function ApplyBusiness() {
|
||||
const router = useRouter();
|
||||
const alertShownRef = useRef(false);
|
||||
const [success, setSucess] = useState(false);
|
||||
|
||||
@ -74,7 +75,7 @@ export default function ApplyBusiness() {
|
||||
text: error == null ? "Your application has been submitted" : error.message,
|
||||
confirmButtonColor: error == null ? "green" : "red",
|
||||
}).then(() => {
|
||||
window.location.href = "/";
|
||||
router.push("/");
|
||||
});
|
||||
};
|
||||
|
||||
@ -97,7 +98,7 @@ export default function ApplyBusiness() {
|
||||
allowEscapeKey: false,
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = "/";
|
||||
router.push("/");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -112,6 +113,7 @@ export default function ApplyBusiness() {
|
||||
};
|
||||
// setSucess(true);
|
||||
fetchUserData();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@ -15,9 +15,11 @@ import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
||||
import { overAllGraphData, fourYearGraphData, dayOftheWeekData } from "../portfolio/[uid]/query";
|
||||
import CountUp from "react-countup";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function Dashboard() {
|
||||
const supabase = createSupabaseClient();
|
||||
const router = useRouter();
|
||||
const { session, loading: isLoadingSession } = useSession();
|
||||
const userId = session?.user.id;
|
||||
const [projects, setProjects] = useState<
|
||||
@ -234,7 +236,7 @@ export default function Dashboard() {
|
||||
</Card>
|
||||
<Button
|
||||
onClick={() => {
|
||||
window.location.href = `/project/${project.id}/edit`;
|
||||
router.push(`/project/${project.id}/edit`);
|
||||
}}
|
||||
className="h-full bg-emerald-500 hover:bg-emerald-800 font-bold text-xl"
|
||||
>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user