From 2d4a75a21a8a97db8017b56e321c56c7d70bc674 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Sat, 29 Jul 2023 01:22:38 +0800
Subject: ...

---
 .../src/pages/setting/ChangeNicknameDialog.tsx     | 29 +++++++++++-----------
 1 file changed, 15 insertions(+), 14 deletions(-)

(limited to 'FrontEnd/src/pages/setting/ChangeNicknameDialog.tsx')

diff --git a/FrontEnd/src/pages/setting/ChangeNicknameDialog.tsx b/FrontEnd/src/pages/setting/ChangeNicknameDialog.tsx
index 58bbac5f..5606ce94 100644
--- a/FrontEnd/src/pages/setting/ChangeNicknameDialog.tsx
+++ b/FrontEnd/src/pages/setting/ChangeNicknameDialog.tsx
@@ -1,6 +1,5 @@
 import { getHttpUserClient } from "@/http/user";
-import { useUser } from "@/services/user";
-import * as React from "react";
+import { useUserLoggedIn } from "@/services/user";
 
 import OperationDialog from "@/views/common/dialog/OperationDialog";
 
@@ -9,26 +8,28 @@ export interface ChangeNicknameDialogProps {
   close: () => void;
 }
 
-const ChangeNicknameDialog: React.FC<ChangeNicknameDialogProps> = (props) => {
-  const user = useUser();
+export default function ChangeNicknameDialog(props: ChangeNicknameDialogProps) {
+  const { open, close } = props;
 
-  if (user == null) return null;
+  const user = useUserLoggedIn();
 
   return (
     <OperationDialog
-      open={props.open}
+      open={open}
       title="settings.dialogChangeNickname.title"
-      inputScheme={[
-        { type: "text", label: "settings.dialogChangeNickname.inputLabel" },
+      inputs={[
+        {
+          key: "newNickname",
+          type: "text",
+          label: "settings.dialogChangeNickname.inputLabel",
+        },
       ]}
-      onProcess={([newNickname]) => {
+      onProcess={({ newNickname }) => {
         return getHttpUserClient().patch(user.username, {
-          nickname: newNickname,
+          nickname: newNickname as string,
         });
       }}
-      close={props.close}
+      close={close}
     />
   );
-};
-
-export default ChangeNicknameDialog;
+}
-- 
cgit v1.2.3

