summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/auth/components/IsAuth.jsx20
-rw-r--r--src/lib/home/components/PreferredBrand.jsx2
2 files changed, 21 insertions, 1 deletions
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
diff --git a/src/lib/home/components/PreferredBrand.jsx b/src/lib/home/components/PreferredBrand.jsx
index fa0fdd0d..3df3cdb7 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -13,7 +13,7 @@ const PreferredBrand = () => {
{!preferredBrands.isLoading && (
<Swiper
slidesPerView={3.5}
- spaceBetween={8}
+ spaceBetween={12}
freeMode
>
{preferredBrands.data?.manufactures.map((brand) => (