mirror of
https://github.com/sigmasternchen/threadule
synced 2025-03-15 08:09:01 +00:00
feat: begin of user settings
This commit is contained in:
parent
254a9440a8
commit
f5c08ef4e5
8 changed files with 86 additions and 9 deletions
|
@ -6,6 +6,7 @@ import PrivateRoute from "./auth/PrivateRoute";
|
||||||
import Login from "./pages/Login";
|
import Login from "./pages/Login";
|
||||||
import Dashboard from "./pages/Dashboard";
|
import Dashboard from "./pages/Dashboard";
|
||||||
import MenuBar from "./components/MenuBar";
|
import MenuBar from "./components/MenuBar";
|
||||||
|
import Settings from "./pages/Settings";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
|
@ -15,10 +16,14 @@ function App() {
|
||||||
<Route path="/login">
|
<Route path="/login">
|
||||||
<Login/>
|
<Login/>
|
||||||
</Route>
|
</Route>
|
||||||
<PrivateRoute path="/">
|
<PrivateRoute exact path="/">
|
||||||
<MenuBar />
|
<MenuBar pageName="Dashboard" />
|
||||||
<Dashboard />
|
<Dashboard />
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
|
<PrivateRoute path="/settings">
|
||||||
|
<MenuBar pageName="Settings" />
|
||||||
|
<Settings />
|
||||||
|
</PrivateRoute>
|
||||||
<Route path="/*">
|
<Route path="/*">
|
||||||
<Redirect to={"/login"} />
|
<Redirect to={"/login"} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
|
@ -3,13 +3,15 @@ import MenuIcon from '@material-ui/icons/Menu';
|
||||||
import {FunctionComponent, useState} from "react";
|
import {FunctionComponent, useState} from "react";
|
||||||
import {useAuth} from "../../auth/AuthProvider";
|
import {useAuth} from "../../auth/AuthProvider";
|
||||||
import {AccountCircle} from "@material-ui/icons";
|
import {AccountCircle} from "@material-ui/icons";
|
||||||
|
import {Link, useHistory} from "react-router-dom";
|
||||||
|
|
||||||
type MenuBarProps = {
|
type MenuBarProps = {
|
||||||
|
pageName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuBar: FunctionComponent<MenuBarProps> = () => {
|
const MenuBar: FunctionComponent<MenuBarProps> = ({pageName}) => {
|
||||||
const { user, logout } = useAuth()
|
const { user, logout } = useAuth()
|
||||||
|
const history = useHistory()
|
||||||
|
|
||||||
const [anchorEl, setAnchorEl] = useState<HTMLElement|null>(null)
|
const [anchorEl, setAnchorEl] = useState<HTMLElement|null>(null)
|
||||||
const open = Boolean(anchorEl);
|
const open = Boolean(anchorEl);
|
||||||
|
@ -29,7 +31,12 @@ const MenuBar: FunctionComponent<MenuBarProps> = () => {
|
||||||
<MenuIcon />
|
<MenuIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography variant="h6" style={{flexGrow: 1}}>
|
<Typography variant="h6" style={{flexGrow: 1}}>
|
||||||
Threadule
|
<Link to={"/"} style={{
|
||||||
|
color: "inherit",
|
||||||
|
textDecoration: "inherit"
|
||||||
|
}}>
|
||||||
|
Threadule - {pageName}
|
||||||
|
</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
<IconButton
|
<IconButton
|
||||||
aria-label="account of current user"
|
aria-label="account of current user"
|
||||||
|
@ -55,6 +62,7 @@ const MenuBar: FunctionComponent<MenuBarProps> = () => {
|
||||||
open={open}
|
open={open}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
>
|
>
|
||||||
|
<MenuItem onClick={() => history.push("/settings")}>Settings</MenuItem>
|
||||||
<MenuItem onClick={logout}>Logout</MenuItem>
|
<MenuItem onClick={logout}>Logout</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
|
23
frontend/src/components/SettingsCard/index.tsx
Normal file
23
frontend/src/components/SettingsCard/index.tsx
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import {FunctionComponent} from "react";
|
||||||
|
import {Card, CardContent, CardHeader, Grid} from "@material-ui/core";
|
||||||
|
|
||||||
|
export type SettingsCardProps = {
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const SettingsCard: FunctionComponent<SettingsCardProps> = ({name, children}) => {
|
||||||
|
return (
|
||||||
|
<Grid item xs={6}>
|
||||||
|
<Card>
|
||||||
|
<CardHeader
|
||||||
|
title={name}
|
||||||
|
/>
|
||||||
|
<CardContent>
|
||||||
|
{children}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SettingsCard
|
|
@ -1,3 +1,8 @@
|
||||||
|
.container {
|
||||||
|
margin-top: 40px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
.addButton {
|
.addButton {
|
||||||
position: fixed !important;
|
position: fixed !important;
|
||||||
bottom: 50px;
|
bottom: 50px;
|
||||||
|
|
|
@ -55,10 +55,7 @@ const Dashboard: FunctionComponent<DashboardProps> = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Grid container style={{
|
<Grid container className={styles.container}>
|
||||||
marginTop: "40px",
|
|
||||||
boxSizing: "border-box",
|
|
||||||
}}>
|
|
||||||
{loading &&
|
{loading &&
|
||||||
<CircularProgress/>
|
<CircularProgress/>
|
||||||
}
|
}
|
||||||
|
|
4
frontend/src/pages/Settings/UserSettings.module.css
Normal file
4
frontend/src/pages/Settings/UserSettings.module.css
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
.container {
|
||||||
|
margin-top: 40px !important;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
14
frontend/src/pages/Settings/UserSettings/index.tsx
Normal file
14
frontend/src/pages/Settings/UserSettings/index.tsx
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import {FunctionComponent} from "react";
|
||||||
|
|
||||||
|
export type UserSettingsProps = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const UserSettings: FunctionComponent<UserSettingsProps> = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default UserSettings
|
21
frontend/src/pages/Settings/index.tsx
Normal file
21
frontend/src/pages/Settings/index.tsx
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import {FunctionComponent} from "react";
|
||||||
|
import SettingsCard from "../../components/SettingsCard";
|
||||||
|
import UserSettings from "./UserSettings";
|
||||||
|
import {Grid} from "@material-ui/core";
|
||||||
|
import styles from "./UserSettings.module.css"
|
||||||
|
|
||||||
|
export type SettingsProps = {}
|
||||||
|
|
||||||
|
const Settings: FunctionComponent<SettingsProps> = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Grid container className={styles.container} spacing={4}>
|
||||||
|
<SettingsCard name={"User"}>
|
||||||
|
<UserSettings/>
|
||||||
|
</SettingsCard>
|
||||||
|
</Grid>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Settings
|
Loading…
Reference in a new issue