From 485678f4079aed4d5b2755c11e24b02bb32110f4 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Mon, 1 Jul 2024 13:25:08 +0200 Subject: App: Save session in localstorage --- package-lock.json | 13 +++++++++++++ package.json | 1 + src/App.tsx | 10 +++++----- 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 ( <> @@ -18,10 +18,10 @@ function App() { } /> - } /> - } /> notfound

} /> -- cgit 1.4.1