From 20c3f5116af5592c00b7139386d92b693a99cd9f Mon Sep 17 00:00:00 2001 From: Oliver Bryan <04oliverbryan@gmail.com> Date: Thu, 1 Jan 2026 04:52:42 +0000 Subject: [PATCH] added functionality for changing name and password --- packages/frontend/src/Account.tsx | 74 ++++++++++++++++++++++++++++++- todo.md | 2 +- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/Account.tsx b/packages/frontend/src/Account.tsx index c4944c3..69246ed 100644 --- a/packages/frontend/src/Account.tsx +++ b/packages/frontend/src/Account.tsx @@ -1,9 +1,81 @@ +import type { UserRecord } from "@issue/shared"; +import { useEffect, useState } from "react"; import { SettingsPageLayout } from "@/components/settings-page-layout"; +import { Button } from "@/components/ui/button"; +import { Field } from "@/components/ui/field"; +import { Label } from "@/components/ui/label"; +import { user } from "@/lib/server"; function Account() { + const [name, setName] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + const [submitAttempted, setSubmitAttempted] = useState(false); + const [userId, setUserId] = useState(null); + + useEffect(() => { + const userStr = localStorage.getItem("user"); + if (userStr) { + const user = JSON.parse(userStr) as UserRecord; + setName(user.name); + setUserId(user.id); + } + }, []); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setSubmitAttempted(true); + + if (name.trim() === "") { + return; + } + + if (!userId) { + setError("User not found"); + return; + } + + await user.update({ + id: userId, + name: name.trim(), + password: password.trim(), + onSuccess: (data) => { + setError(""); + localStorage.setItem("user", JSON.stringify(data)); + setPassword(""); + }, + onError: (errorMessage) => { + setError(errorMessage); + }, + }); + }; + return ( -

Account page here

+
+ setName(e.target.value)} + validate={(v) => (v.trim() === "" ? "Cannot be empty" : undefined)} + submitAttempted={submitAttempted} + /> + setPassword(e.target.value)} + placeholder="Leave empty to keep current password" + hidden={true} + /> + + {error !== "" && } + +
+ +
+
); } diff --git a/todo.md b/todo.md index 815a80d..613efbe 100644 --- a/todo.md +++ b/todo.md @@ -1,4 +1,3 @@ -- user settings/profile page - org settings - add/invite user(s) to org - issues @@ -6,3 +5,4 @@ - issue assignee - deadline - time tracking (linked to issues or standalone) +- user avatars