From b8507c5a568a7c24899a5712576d9c675395d18a Mon Sep 17 00:00:00 2001
From: Michelle Lim <18221052@std.stei.itb.ac.id>
Date: Sat, 25 Nov 2023 18:48:38 +0900
Subject: [PATCH] fix: added readiness check

---
 pages/instruktur/edit/[id].jsx     | 3 ++-
 pages/kelasmengemudi/edit/[id].jsx | 4 +++-
 pages/kendaraan/edit/[id].jsx      | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pages/instruktur/edit/[id].jsx b/pages/instruktur/edit/[id].jsx
index 72d0ede..be1fd0c 100644
--- a/pages/instruktur/edit/[id].jsx
+++ b/pages/instruktur/edit/[id].jsx
@@ -44,6 +44,7 @@ const Edit = () => {
   }
 
   useEffect(() => {
+    if (!router.isReady) return;
     const token = window.localStorage.getItem("token")
     if (token === undefined || token === null) {
       window.location.replace("/auth/login")
@@ -67,7 +68,7 @@ const Edit = () => {
       setRekening(responsejson.data.noRekening)
     })
     //eslint-disable-next-line
-  }, [])
+  }, [router.isReady])
   return <>
     <Template>
       <main className="min-h-screen px-14 py-5 bg-[#FFF6F6]">
diff --git a/pages/kelasmengemudi/edit/[id].jsx b/pages/kelasmengemudi/edit/[id].jsx
index fc209a9..b717ed1 100644
--- a/pages/kelasmengemudi/edit/[id].jsx
+++ b/pages/kelasmengemudi/edit/[id].jsx
@@ -52,6 +52,7 @@ const Edit = () => {
   }
 
   useEffect(() => {
+    if (!router.isReady) return
     const token = window.localStorage.getItem("token")
     if (token === undefined || token === null) {
       window.location.replace("/auth/login")
@@ -78,7 +79,8 @@ const Edit = () => {
       setNomorKendaraan(responsejson.data.kendaraan)
       setNamaKendaraan(responsejson.data.calonPelanggan)
     })
-  }, [])
+    //eslint-disable-next-line
+  }, [router.isReady])
   return <>
     <Template>
       <main className="min-h-screen px-14 py-5 bg-[#FFF6F6]">
diff --git a/pages/kendaraan/edit/[id].jsx b/pages/kendaraan/edit/[id].jsx
index 0119a4a..9a2f1c5 100644
--- a/pages/kendaraan/edit/[id].jsx
+++ b/pages/kendaraan/edit/[id].jsx
@@ -46,6 +46,7 @@ const Edit = () => {
   }
 
   useEffect(() => {
+    if (!router.isReady) return;
     const token = window.localStorage.getItem("token")
     if (token === undefined || token === null) {
       window.location.replace("/auth/login")
@@ -71,7 +72,7 @@ const Edit = () => {
       setStatusKendaraan(responsejson.data.statusKendaraan)
     })
     //eslint-disable-next-line
-  }, [])
+  }, [router.isReady])
   return <>
     <Template>
       <main className="min-h-screen px-14 py-5 bg-[#FFF6F6]">
-- 
GitLab