"...com/t_oster/git@gitlab.liu.se:admittansen/LibLaserCut.git" did not exist on "57565d51ddd3a6b74fd5232392059ef3b7aec12d"
Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import {
AppBar,
Button,
CssBaseline,
Divider,
Drawer,
List,
ListItem,
ListItemIcon,
ListItemText,
Toolbar,
Typography
} from '@material-ui/core'
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'
import DashboardIcon from '@material-ui/icons/Dashboard'
import MailIcon from '@material-ui/icons/Mail'
import React from 'react'
import { Link, Route, Switch, useRouteMatch } from 'react-router-dom'
import './AdminView.css'
import CompetitionManager from './CompetitionManager'
import Regions from './Regions'
const drawerWidth = 240
const menuItems = ['Startsida', 'Regioner', 'Användare', 'Tävlingshanterare']
const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
display: 'flex'
},
appBar: {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: drawerWidth
},
drawer: {
width: drawerWidth,
flexShrink: 0,
marginRight: drawerWidth
},
drawerPaper: {
width: drawerWidth
},
// necessary for content to be below app bar
toolbar: theme.mixins.toolbar,
content: {
flexGrow: 1,
backgroundColor: theme.palette.background.default,
paddingLeft: theme.spacing(30)
}
})
)
const AdminView: React.FC = (props) => {
const classes = useStyles()
const [openIndex, setOpenIndex] = React.useState(0)
const match = useRouteMatch()
console.log(match)
const { path, url } = match
return (
<div className={classes.root}>
<CssBaseline />
<AppBar position="fixed" className={classes.appBar}>
<Toolbar>
<Typography variant="h5" noWrap>
{menuItems[openIndex]}
</Typography>
</Toolbar>
</AppBar>
<Drawer
className={(classes.drawer, 'background')}
variant="permanent"
classes={{
paper: classes.drawerPaper
}}
anchor="left"
>
<div className="background">
<div className={classes.toolbar} />
<Divider />
<List>
{menuItems.map((text, index) => (
<ListItem
button
component={Link}
key={text}
to={`${url}/${text.toLowerCase()}`}
selected={index === openIndex}
onClick={() => setOpenIndex(index)}
>
<ListItemIcon>
{text === 'Dashboard' ? <DashboardIcon /> : <MailIcon />}
</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
</List>
<Divider />
<List>
<ListItem>
<Button
component={Link}
to="/"
type="submit"
fullWidth
variant="contained"
color="primary"
>
Logga ut
</Button>
</ListItem>
</List>
</div>
</Drawer>
<main className={classes.content}>
<div className={classes.toolbar} />
<Switch>
<Route exact path={[path, `${path}/startsida`]}>
<Typography variant="h1" noWrap>
Startsida
</Typography>
</Route>
<Route path={`${path}/regioner`}>
<Regions />
</Route>
<Route path={`${path}/användare`}>
<Typography variant="h1" noWrap>
Användare
</Typography>
</Route>
<Route path={`${path}/tävlingshanterare`}>
<CompetitionManager />
</Route>
</Switch>
</main>
</div>
)
}
export default AdminView