From e820c2864848c5dd3f801462d6aee0f59827ab14 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 13 May 2021 09:27:12 +0200 Subject: [PATCH] Ready to create account settings route --- src/helpers/AccountHelper.ts | 11 ++++++++ src/ui/routes/AccountSettingsRoute.tsx | 35 +++++++++++++++++++++++ src/ui/routes/HomeRoute.tsx | 2 +- src/ui/routes/MainRoute.tsx | 39 ++++++++++++++++---------- 4 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 src/ui/routes/AccountSettingsRoute.tsx diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 7e839e4..3947137 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -65,6 +65,17 @@ export class AccountHelper { sessionStorage.setItem(SESSION_STORAGE_TOKEN, res.token); } + /** + * Get information about an administrator + * + * @param id The ID of the target administrator + */ + static async getAdminInfo(id: number): Promise { + return await serverRequest("accounts/info", { + id: id, + }); + } + /** * Attempt to refresh current account information */ diff --git a/src/ui/routes/AccountSettingsRoute.tsx b/src/ui/routes/AccountSettingsRoute.tsx new file mode 100644 index 0000000..c9299e4 --- /dev/null +++ b/src/ui/routes/AccountSettingsRoute.tsx @@ -0,0 +1,35 @@ +/** + * Account settings route + * + * @author Pierre Hubert + */ + +import React from "react"; +import { useParams } from "react-router-dom"; + +export function AccountSettingsRoute() { + let params: any = useParams(); + + return ; +} + +interface SettingsRouteProps { + id: number; +} + +interface SettingsRouteState {} + +class AccountSettingsRouteInner extends React.Component< + SettingsRouteProps, + SettingsRouteState +> { + constructor(props: any) { + super(props); + + this.state = {}; + } + + render() { + return
"hello {this.props.id}
; + } +} diff --git a/src/ui/routes/HomeRoute.tsx b/src/ui/routes/HomeRoute.tsx index a7ad111..c57d619 100644 --- a/src/ui/routes/HomeRoute.tsx +++ b/src/ui/routes/HomeRoute.tsx @@ -1,3 +1,3 @@ export function HomeRoute() { - return

Welcome to Comunic Console!

; + return

Welcome to the Comunic Console!

; } diff --git a/src/ui/routes/MainRoute.tsx b/src/ui/routes/MainRoute.tsx index 8f0cdd5..5cab5ac 100644 --- a/src/ui/routes/MainRoute.tsx +++ b/src/ui/routes/MainRoute.tsx @@ -6,8 +6,6 @@ import { AppBar, - Badge, - Divider, IconButton, List, ListItem, @@ -18,16 +16,19 @@ import { Toolbar, Typography, } from "@material-ui/core"; -import DraftsIcon from "@material-ui/icons/Drafts"; -import InboxIcon from "@material-ui/icons/Inbox"; -import NotificationsIcon from "@material-ui/icons/Notifications"; -import React from "react"; -import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; -import { AccountHelper } from "../../helpers/AccountHelper"; -import CloseSharpIcon from "@material-ui/icons/CloseSharp"; -import { NotFoundRoute } from "./NotFoundRoute"; -import { HomeRoute } from "./HomeRoute"; import { Home, Person } from "@material-ui/icons"; +import CloseSharpIcon from "@material-ui/icons/CloseSharp"; +import React from "react"; +import { + BrowserRouter as Router, + Route, + Switch, + useHistory, +} from "react-router-dom"; +import { AccountHelper } from "../../helpers/AccountHelper"; +import { AccountSettingsRoute } from "./AccountSettingsRoute"; +import { HomeRoute } from "./HomeRoute"; +import { NotFoundRoute } from "./NotFoundRoute"; const useStyles = makeStyles((theme) => ({ root: { @@ -79,18 +80,22 @@ const useStyles = makeStyles((theme) => ({ })); function Menu() { - const classes = useStyles(); + const history = useHistory(); + + const openHome = () => history.push("/"); + const openMyAccount = () => + history.push("/accounts/" + AccountHelper.currentAccount.id); return (
- + - + @@ -123,7 +128,7 @@ export function MainRoute() { noWrap className={classes.title} > - Comunic Admin + Comunic Console @@ -156,6 +161,10 @@ export function MainRoute() { + + + +