From ffa261e6adef70a2845878cf93e6e492eb8cee62 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 27 Feb 2023 10:49:45 +0700
Subject: footer

---
 src/lib/auth/components/IsAuth.jsx | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 src/lib/auth/components/IsAuth.jsx

(limited to 'src/lib/auth/components/IsAuth.jsx')

diff --git a/src/lib/auth/components/IsAuth.jsx b/src/lib/auth/components/IsAuth.jsx
new file mode 100644
index 00000000..1cfd3172
--- /dev/null
+++ b/src/lib/auth/components/IsAuth.jsx
@@ -0,0 +1,20 @@
+import { useRouter } from 'next/router'
+import { useEffect, useState } from 'react'
+import { getAuth } from '@/core/utils/auth'
+
+const IsAuth = ({ children }) => {
+  const router = useRouter()
+  const [response, setResponse] = useState(<></>)
+
+  useEffect(() => {
+    if (!getAuth()) {
+      router.replace('/login')
+    } else {
+      setResponse(children)
+    }
+  }, [children, router])
+
+  return response
+}
+
+export default IsAuth
-- 
cgit v1.2.3

