about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-07-01 13:25:08 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-07-01 13:25:08 +0200
commit485678f4079aed4d5b2755c11e24b02bb32110f4 (patch)
treec47c309b40366d3fe82be5aff86b0d97d736796a
parentMisc: Fix tsx warnings (diff)
downloadfs-tracer-frontend-485678f4079aed4d5b2755c11e24b02bb32110f4.tar.gz
fs-tracer-frontend-485678f4079aed4d5b2755c11e24b02bb32110f4.tar.bz2
fs-tracer-frontend-485678f4079aed4d5b2755c11e24b02bb32110f4.zip
App: Save session in localstorage
-rw-r--r--package-lock.json13
-rw-r--r--package.json1
-rw-r--r--src/App.tsx10
3 files changed, 19 insertions, 5 deletions
diff --git a/package-lock.json b/package-lock.json
index 4eec2a0..f01340a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,6 +10,7 @@
       "dependencies": {
         "@react-oauth/google": "^0.12.1",
         "@supabase/supabase-js": "^2.43.4",
+        "@uidotdev/usehooks": "^2.4.1",
         "chart.js": "^4.4.3",
         "react": "^18.2.0",
         "react-chartjs-2": "^5.2.0",
@@ -1060,6 +1061,18 @@
         "url": "https://opencollective.com/typescript-eslint"
       }
     },
+    "node_modules/@uidotdev/usehooks": {
+      "version": "2.4.1",
+      "resolved": "https://registry.npmjs.org/@uidotdev/usehooks/-/usehooks-2.4.1.tgz",
+      "integrity": "sha512-1I+RwWyS+kdv3Mv0Vmc+p0dPYH0DTRAo04HLyXReYBL9AeseDWUJyi4THuksBJcu9F0Pih69Ak150VDnqbVnXg==",
+      "engines": {
+        "node": ">=16"
+      },
+      "peerDependencies": {
+        "react": ">=18.0.0",
+        "react-dom": ">=18.0.0"
+      }
+    },
     "node_modules/@ungap/structured-clone": {
       "version": "1.2.0",
       "dev": true,
diff --git a/package.json b/package.json
index 19fe8fe..8d19c23 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
   "dependencies": {
     "@react-oauth/google": "^0.12.1",
     "@supabase/supabase-js": "^2.43.4",
+    "@uidotdev/usehooks": "^2.4.1",
     "chart.js": "^4.4.3",
     "react": "^18.2.0",
     "react-chartjs-2": "^5.2.0",
diff --git a/src/App.tsx b/src/App.tsx
index 61f7b8b..ffbb8f3 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,16 +1,16 @@
-import { useState } from 'react'
-
 import { BrowserRouter, Routes, Route } from "react-router-dom";
 import { createClient } from '@supabase/supabase-js'
 
 import Home from './pages/Home'
 import Login from './pages/Login'
 import Logout from './pages/Logout';
+import Recent from './pages/Recent';
+import { useLocalStorage } from "@uidotdev/usehooks";
 
 const supabase = createClient('https://slpoocycjgqsuoedhkbn.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNscG9vY3ljamdxc3VvZWRoa2JuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTUyMDU0MjUsImV4cCI6MjAzMDc4MTQyNX0.xZYRTRN65rlms1Hb96IBAQvw3EGtMzUxlGPP5TVey34')
 
 function App() {
-  const [session, setSession] = useState(null)
+  const [session, setSession] = useLocalStorage("session", null)
   return (
     <>
       <BrowserRouter basename={import.meta.env.DEV ? '/' : '/fs-tracer-frontend'}>
@@ -18,10 +18,10 @@ function App() {
           <Route index element={
             <Home supabase={supabase} session={session} />
           } />
-          <Route path="login" element={
+          <Route path="/login" element={
             <Login supabase={supabase} session={session} setSession={setSession} />
           } />
-          <Route path="logout" element={
+          <Route path="/logout" element={
             <Logout supabase={supabase} session={session} setSession={setSession} />
           } />
           <Route path="*" element={<p>notfound</p>} />