From 99e8a0e5360f397c5bbac5ae1a952cba98cf54fb Mon Sep 17 00:00:00 2001
From: Biswakalyan Bhuyan <biswa@surgot.in>
Date: Thu, 25 Jul 2024 23:29:15 +0530
Subject: added login and registation methods

---
 src/utils/PrivateRoute.jsx | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 src/utils/PrivateRoute.jsx

(limited to 'src/utils/PrivateRoute.jsx')

diff --git a/src/utils/PrivateRoute.jsx b/src/utils/PrivateRoute.jsx
new file mode 100644
index 0000000..b57bcf5
--- /dev/null
+++ b/src/utils/PrivateRoute.jsx
@@ -0,0 +1,9 @@
+import React from 'react';
+import { Navigate } from 'react-router-dom';
+
+const PrivateRoute = ({ children }) => {
+  const token = localStorage.getItem('token');
+  return token ? children : <Navigate to="/" />;
+};
+
+export default PrivateRoute;
-- 
cgit v1.2.3-59-g8ed1b

