From e45036dec372b41f269b6cf7cf03e20cb135fec8 Mon Sep 17 00:00:00 2001 From: AINDUSTRIES Date: Tue, 28 Jul 2026 20:22:05 +0200 Subject: [PATCH] Settings ui trial --- app/components/settings.tsx | 55 +++++++++++++++++++++++++++++++++++++ app/components/user.tsx | 15 +++++++--- app/hooks/auth.tsx | 39 ++++++++------------------ 3 files changed, 78 insertions(+), 31 deletions(-) create mode 100644 app/components/settings.tsx diff --git a/app/components/settings.tsx b/app/components/settings.tsx new file mode 100644 index 0000000..e338d04 --- /dev/null +++ b/app/components/settings.tsx @@ -0,0 +1,55 @@ +import { Modal, Button, InputGroup, Input, TextField } from "@heroui/react"; +import type { Dispatch, SetStateAction } from "react"; +import { useAuth } from "~/hooks/auth"; + +export function Settings({ + show, + setShow, +}: { + show: boolean; + setShow: Dispatch>; +}) { + const {user, loading, login, logout} = useAuth(); + return ( +
+ + { + setShow(false); + return true; + }} + > + + + { + setShow(false); + }} + /> + + Account settings + + + + Username + + + + + + + + + + + +
+ ); +} diff --git a/app/components/user.tsx b/app/components/user.tsx index 1680378..913627e 100644 --- a/app/components/user.tsx +++ b/app/components/user.tsx @@ -7,11 +7,15 @@ import { Separator, Spinner, } from "@heroui/react"; -import type { PropsWithChildren } from "react"; +import { useState, type PropsWithChildren } from "react"; import { useAuth } from "~/hooks/auth"; +import { Settings } from "./settings"; export default function User({ children }: PropsWithChildren) { const { user, loading, login, logout } = useAuth(); + const [showSettings, setShowSettings] = useState(false); + + const toggleSettings = () => {setShowSettings(true)} if (loading) { return ( @@ -30,6 +34,8 @@ export default function User({ children }: PropsWithChildren) { } return ( + <> + handleAction(String(key), logout)} + onAction={(key) => handleAction(String(key), logout, toggleSettings)} > @@ -56,12 +62,13 @@ export default function User({ children }: PropsWithChildren) { + ); } -function handleAction(key: string, logout: () => Promise) { +function handleAction(key: string, logout: () => Promise, toggleSettings: () => void) { if (key === "settings") { - console.log("settings"); + toggleSettings(); } else { logout(); } diff --git a/app/hooks/auth.tsx b/app/hooks/auth.tsx index 9674140..e8ed6d9 100644 --- a/app/hooks/auth.tsx +++ b/app/hooks/auth.tsx @@ -68,18 +68,6 @@ export function AuthProvider({ children }: PropsWithChildren) { 10000, ); }); - if (response === "nok") { - notify( - { - type: "danger", - loading: false, - title: "An error occured.", - message: - "An error occured during the information exchange between Steam and Porning.", - }, - 10000, - ); - } } let data = await fetch(`${import.meta.env.VITE_BASE_API_URL}/me`, { @@ -98,20 +86,9 @@ export function AuthProvider({ children }: PropsWithChildren) { ); }); - if (data === null) { - notify( - { - type: "danger", - loading: false, - title: "An error occured.", - message: - "An error occured while trying to fetch your user profile. Please contact an administrator.", - }, - 10000, - ); - } else if (data !== undefined) { - setUser(data); - notify( + if (data !== undefined) { + setUser(data); + notify( { type: "success", loading: false, @@ -140,7 +117,15 @@ export function AuthProvider({ children }: PropsWithChildren) { }) .then(() => { setUser(null); - notify({type: "success", loading: false, title: "Logout successful!", message: ""}, 2000) + notify( + { + type: "success", + loading: false, + title: "Logout successful!", + message: "", + }, + 2000, + ); }) .catch((e) => { notify(