From 104341ddc4add57f83c58cb3fabb23b6fbfdd3e4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 2 Nov 2025 00:00:35 +0900 Subject: wip --- frontend/src/App.tsx | 35 +++++--- frontend/src/components/Navigation.tsx | 26 +++++- frontend/src/components/ProtectedRoute.tsx | 32 +++++++ frontend/src/components/index.ts | 1 + frontend/src/contexts/AuthContext.tsx | 95 +++++++++++++++++++++ frontend/src/graphql/generated/gql.ts | 12 +-- frontend/src/graphql/generated/graphql.ts | 50 ++++++++++- frontend/src/graphql/mutations.graphql | 13 +++ frontend/src/graphql/queries.graphql | 7 ++ frontend/src/main.tsx | 9 +- frontend/src/pages/Login.tsx | 133 +++++++++++++++++++++++++++++ frontend/src/pages/index.ts | 1 + frontend/src/services/graphql-client.ts | 4 + 13 files changed, 395 insertions(+), 23 deletions(-) create mode 100644 frontend/src/components/ProtectedRoute.tsx create mode 100644 frontend/src/contexts/AuthContext.tsx create mode 100644 frontend/src/pages/Login.tsx (limited to 'frontend') diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 02db0ca..58b6687 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,18 +1,31 @@ import { Redirect, Route, Switch } from "wouter"; -import { Layout } from "./components"; -import { NotFound, ReadArticles, Settings, UnreadArticles } from "./pages"; +import { Layout, ProtectedRoute } from "./components"; +import { + Login, + NotFound, + ReadArticles, + Settings, + UnreadArticles, +} from "./pages"; function App() { return ( - - - } /> - - - - - - + + + + + + + } /> + + + + + + + + + ); } diff --git a/frontend/src/components/Navigation.tsx b/frontend/src/components/Navigation.tsx index 08a523f..d6e20c9 100644 --- a/frontend/src/components/Navigation.tsx +++ b/frontend/src/components/Navigation.tsx @@ -2,11 +2,22 @@ import { faBookOpen, faCircleCheck, faGear, + faRightFromBracket, } from "@fortawesome/free-solid-svg-icons"; -import { Link } from "wouter"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Link, useLocation } from "wouter"; +import { useAuth } from "../contexts/AuthContext"; import { MenuItem } from "./MenuItem"; export function Navigation() { + const { logout, user } = useAuth(); + const [, setLocation] = useLocation(); + + const handleLogout = async () => { + await logout(); + setLocation("/login"); + }; + return (