diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index 8e19876..ee64b05 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -28,7 +28,7 @@ const Header: React.FC = () => { - {user?.displayName} + {user.nickname} } diff --git a/web/src/components/ShortcutListView.tsx b/web/src/components/ShortcutListView.tsx index d2a2bd6..125c8bc 100644 --- a/web/src/components/ShortcutListView.tsx +++ b/web/src/components/ShortcutListView.tsx @@ -64,7 +64,7 @@ const ShortcutListView: React.FC = (props: Props) => { ({shortcut.description})
- {shortcut.creator.displayName} + {shortcut.creator.nickname} + } + actions={ + <> + + + } + actionsClassName="!w-32" + /> +
{loadingState.isLoading ? (
@@ -37,6 +73,10 @@ const Home: React.FC = () => { )}
+ + {state.showCreateShortcutDialog && ( + setShowCreateShortcutDialog(false)} onConfirm={() => setShowCreateShortcutDialog(false)} /> + )} ); }; diff --git a/web/src/pages/ShortcutRedirector.tsx b/web/src/pages/ShortcutRedirector.tsx deleted file mode 100644 index 248d0b4..0000000 --- a/web/src/pages/ShortcutRedirector.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { useEffect, useState } from "react"; -import { useParams } from "react-router-dom"; -import { getShortcutWithNameAndWorkspaceName } from "../helpers/api"; -import useLoading from "../hooks/useLoading"; - -interface State { - errMessage?: string; -} - -const ShortcutRedirector: React.FC = () => { - const params = useParams(); - const [state, setState] = useState(); - const loadingState = useLoading(); - - useEffect(() => { - const workspaceName = params.workspaceName || ""; - const shortcutName = params.shortcutName || ""; - getShortcutWithNameAndWorkspaceName(workspaceName, shortcutName) - .then(({ data: shortcut }) => { - if (shortcut) { - window.location.href = shortcut.link; - } else { - setState({ - errMessage: "Not found", - }); - loadingState.setFinish(); - } - }) - .catch((error) => { - setState({ - errMessage: error.response.data.error || "Error occurred", - }); - loadingState.setFinish(); - }); - }, []); - - return loadingState.isLoading ? null : ( -
-

{state?.errMessage}

-
- ); -}; - -export default ShortcutRedirector; diff --git a/web/src/pages/UserDetail.tsx b/web/src/pages/UserDetail.tsx index 530d26f..8fe8300 100644 --- a/web/src/pages/UserDetail.tsx +++ b/web/src/pages/UserDetail.tsx @@ -1,12 +1,8 @@ -import { Button, Input, Tooltip } from "@mui/joy"; +import { Button } from "@mui/joy"; import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; -import toast from "react-hot-toast"; import { useAppSelector } from "../store"; -import { showCommonDialog } from "../components/Alert"; import { userService } from "../services"; -import Icon from "../components/Icon"; -import copy from "copy-to-clipboard"; import ChangePasswordDialog from "../components/ChangePasswordDialog"; interface State { @@ -20,11 +16,13 @@ const UserDetail: React.FC = () => { showChangePasswordDialog: false, }); + console.log("here"); useEffect(() => { if (!userService.getState().user) { navigate("/user/auth"); return; } + console.log("here"); }, []); const handleChangePasswordBtnClick = async () => { @@ -34,34 +32,10 @@ const UserDetail: React.FC = () => { }); }; - const handleCopyOpenIdBtnClick = async () => { - if (!user?.openId) { - toast.error("OpenID not found"); - return; - } - - copy(user.openId); - toast.success("OpenID copied"); - }; - - const handleResetOpenIdBtnClick = async () => { - showCommonDialog({ - title: "Reset Open API", - content: "❗️The existing API will be invalidated and a new one will be generated, are you sure you want to reset?", - style: "warning", - onConfirm: async () => { - await userService.patchUser({ - id: user?.id as UserId, - resetOpenId: true, - }); - }, - }); - }; - return ( <>
-

{user?.displayName}

+

{user?.nickname}

Email: {user?.email} @@ -72,21 +46,6 @@ const UserDetail: React.FC = () => { Change

- {/* Do not display open api related field right now. */} - {false && ( -
- OpenID: - - - - - -
- )} {state.showChangePasswordDialog && ( diff --git a/web/src/router/index.tsx b/web/src/router/index.tsx index ca02e15..bae5f30 100644 --- a/web/src/router/index.tsx +++ b/web/src/router/index.tsx @@ -5,7 +5,6 @@ import Root from "../layout/Root"; import Auth from "../pages/Auth"; import Home from "../pages/Home"; import UserDetail from "../pages/UserDetail"; -import ShortcutRedirector from "../pages/ShortcutRedirector"; const router = createBrowserRouter([ { @@ -30,6 +29,7 @@ const router = createBrowserRouter([ if (isNullorUndefined(user)) { return redirect("/user/auth"); } + return null; }, }, { @@ -46,14 +46,11 @@ const router = createBrowserRouter([ if (isNullorUndefined(user)) { return redirect("/user/auth"); } + return null; }, }, ], }, - { - path: "/:shortcutName", - element: , - }, ]); export default router; diff --git a/web/src/types/modules/user.d.ts b/web/src/types/modules/user.d.ts index 9867e23..50fc6ae 100644 --- a/web/src/types/modules/user.d.ts +++ b/web/src/types/modules/user.d.ts @@ -9,9 +9,9 @@ interface User { updatedTs: TimeStamp; rowStatus: RowStatus; + username: string; + nickname: string; email: string; - displayName: string; - openId: string; role: Role; }