From 2d9ef25d6171890496b1c9dd48a91b11c40eca7c Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Mon, 6 Dec 2021 20:46:35 +0800
Subject: ...

---
 FrontEnd/src/views/admin/Admin.tsx | 47 +++++++++++---------------------------
 1 file changed, 13 insertions(+), 34 deletions(-)

(limited to 'FrontEnd/src/views/admin/Admin.tsx')

diff --git a/FrontEnd/src/views/admin/Admin.tsx b/FrontEnd/src/views/admin/Admin.tsx
index e750621c..adb1e458 100644
--- a/FrontEnd/src/views/admin/Admin.tsx
+++ b/FrontEnd/src/views/admin/Admin.tsx
@@ -1,48 +1,27 @@
-import React, { Fragment } from "react";
-import { Redirect, Route, Switch, useRouteMatch, match } from "react-router";
+import React from "react";
+import { Route, Routes } from "react-router-dom";
 import { useTranslation } from "react-i18next";
 
-import { AuthUser } from "@/services/user";
-
 import AdminNav from "./AdminNav";
 import UserAdmin from "./UserAdmin";
 import MoreAdmin from "./MoreAdmin";
 
 import "./index.css";
 
-interface AdminProps {
-  user: AuthUser;
-}
-
-const Admin: React.FC<AdminProps> = ({ user }) => {
+const Admin: React.FC = () => {
   useTranslation("admin");
 
-  const match = useRouteMatch();
-
   return (
-    <Fragment>
-      <Switch>
-        <Redirect from={match.path} to={`${match.path}/users`} exact />
-        <Route path={`${match.path}/:name`}>
-          {(p) => {
-            const match = p.match as match<{ name: string }>;
-            const name = match.params["name"];
-            return (
-              <div className="container">
-                <AdminNav className="mt-2" />
-                {(() => {
-                  if (name === "users") {
-                    return <UserAdmin user={user} />;
-                  } else if (name === "more") {
-                    return <MoreAdmin user={user} />;
-                  }
-                })()}
-              </div>
-            );
-          }}
-        </Route>
-      </Switch>
-    </Fragment>
+    <>
+      <div className="container">
+        <AdminNav className="mt-2" />
+        <Routes>
+          <Route index element={<UserAdmin />} />
+          <Route path="/admin/user" element={<UserAdmin />} />
+          <Route path="/admin/more" element={<MoreAdmin />} />
+        </Routes>
+      </div>
+    </>
   );
 };
 
-- 
cgit v1.2.3

