From 93a90bd8904ffda3686c8308657f69b1782d6e24 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Mon, 15 Feb 2021 01:08:05 +0800
Subject: refactor: Refactor timeline card.

---
 FrontEnd/src/app/views/user/index.tsx | 44 ++++-------------------------------
 1 file changed, 5 insertions(+), 39 deletions(-)

(limited to 'FrontEnd/src/app/views/user/index.tsx')

diff --git a/FrontEnd/src/app/views/user/index.tsx b/FrontEnd/src/app/views/user/index.tsx
index 9b5acbba..57454d0d 100644
--- a/FrontEnd/src/app/views/user/index.tsx
+++ b/FrontEnd/src/app/views/user/index.tsx
@@ -1,58 +1,24 @@
-import React, { useState } from "react";
+import React from "react";
 import { useParams } from "react-router";
 
-import { getHttpUserClient } from "@/http/user";
-
 import TimelinePageTemplate from "../timeline-common/TimelinePageTemplate";
-import UserPageUI from "./UserPageUI";
-import { PersonalTimelineManageItem } from "./UserInfoCard";
-import ChangeNicknameDialog from "./ChangeNicknameDialog";
-import ChangeAvatarDialog from "./ChangeAvatarDialog";
+import UserCard from "./UserCard";
 
-const UserPage: React.FC = (_) => {
+const UserPage: React.FC = () => {
   const { username } = useParams<{ username: string }>();
 
-  const [dialog, setDialog] = useState<null | PersonalTimelineManageItem>(null);
-
   const [reloadKey, setReloadKey] = React.useState<number>(0);
 
   let dialogElement: React.ReactElement | undefined;
 
-  const closeDialog = (): void => setDialog(null);
-
-  if (dialog === "nickname") {
-    dialogElement = (
-      <ChangeNicknameDialog
-        open
-        close={closeDialog}
-        onProcess={async (newNickname) => {
-          await getHttpUserClient().patch(username, { nickname: newNickname });
-          setReloadKey(reloadKey + 1);
-        }}
-      />
-    );
-  } else if (dialog === "avatar") {
-    dialogElement = (
-      <ChangeAvatarDialog
-        open
-        close={closeDialog}
-        process={async (file) => {
-          await getHttpUserClient().putAvatar(username, file);
-          setReloadKey(reloadKey + 1);
-        }}
-      />
-    );
-  }
-
   return (
     <>
       <TimelinePageTemplate
-        name={`@${username}`}
-        UiComponent={UserPageUI}
-        onManage={(item) => setDialog(item)}
+        timelineName={`@${username}`}
         notFoundI18nKey="timeline.userNotExist"
         reloadKey={reloadKey}
         onReload={() => setReloadKey(reloadKey + 1)}
+        CardComponent={UserCard}
       />
       {dialogElement}
     </>
-- 
cgit v1.2.3

