|
1 | 1 | import { useEffect, useState, MouseEvent } from 'react';
|
2 |
| -import { useRouter} from 'next/router'; |
| 2 | +import Head from 'next/head'; |
| 3 | +import { useRouter } from 'next/router'; |
3 | 4 | import styled from 'styled-components';
|
4 | 5 | import {
|
5 | 6 | CssBaseline,
|
@@ -247,97 +248,105 @@ const AdminIndexPage = () => {
|
247 | 248 | setProfileAnchorEl(null);
|
248 | 249 | };
|
249 | 250 |
|
250 |
| - return currentUser !== null ? ( |
251 |
| - <AuthProvider> |
252 |
| - <CssBaseline /> |
253 |
| - <div className={classes.root}> |
254 |
| - <AppBar position="static"> |
255 |
| - <Toolbar> |
256 |
| - <Typography variant="h6" className={classes.title}> |
257 |
| - Admin |
258 |
| - </Typography> |
259 |
| - <Typography variant="h6" className={classes.title}> |
260 |
| - Profile:{' '} |
261 |
| - {currentProfile} |
262 |
| - </Typography> |
263 |
| - <Box sx={{ flexGrow: 1 }} /> |
264 |
| - <Box sx={{ display: { xs: 'none', md: 'flex' } }}> |
265 |
| - <IconButton |
266 |
| - size="large" |
267 |
| - color="inherit" |
268 |
| - edge="end" |
269 |
| - aria-controls={profileMenuId} |
270 |
| - aria-haspopup="true" |
271 |
| - aria-expanded={isProfileMenuOpen ? 'true' : undefined} |
272 |
| - onClick={handleProfileMenuOpen} |
273 |
| - > |
274 |
| - <WidgetsIcon /> |
275 |
| - </IconButton> |
276 |
| - <IconButton |
277 |
| - size="large" |
278 |
| - color="inherit" |
279 |
| - onClick={()=>{setAddWidgetDialogOpened(true);}} |
280 |
| - > |
281 |
| - <AddIcon /> |
282 |
| - </IconButton> |
283 |
| - <IconButton |
284 |
| - size="large" |
285 |
| - color="inherit" |
286 |
| - edge="end" |
287 |
| - aria-controls={userMenuId} |
288 |
| - aria-haspopup="true" |
289 |
| - aria-expanded={isUserMenuOpen ? 'true' : undefined} |
290 |
| - onClick={handleUserMenuOpen} |
291 |
| - > |
292 |
| - <AccountCircleIcon /> |
293 |
| - </IconButton> |
294 |
| - </Box> |
295 |
| - </Toolbar> |
296 |
| - </AppBar> |
297 |
| - <Menu |
298 |
| - id={profileMenuId} |
299 |
| - anchorEl={profileAnchorEl} |
300 |
| - open={isProfileMenuOpen} |
301 |
| - onClose={handleProfileMenuClose} |
| 251 | + return ( |
| 252 | + <> |
| 253 | + <Head> |
| 254 | + <title>{currentProfile} : Admin - Raduwen OBS Widgets</title> |
| 255 | + </Head> |
| 256 | + { |
| 257 | + currentUser !== null ? ( |
| 258 | + <AuthProvider> |
| 259 | + <CssBaseline /> |
| 260 | + <div className={classes.root}> |
| 261 | + <AppBar position="static"> |
| 262 | + <Toolbar> |
| 263 | + <Typography variant="h6" className={classes.title}> |
| 264 | + Admin |
| 265 | + </Typography> |
| 266 | + <Typography variant="h6" className={classes.title}> |
| 267 | + Profile:{' '} |
| 268 | + {currentProfile} |
| 269 | + </Typography> |
| 270 | + <Box sx={{ flexGrow: 1 }} /> |
| 271 | + <Box sx={{ display: { xs: 'none', md: 'flex' } }}> |
| 272 | + <IconButton |
| 273 | + size="large" |
| 274 | + color="inherit" |
| 275 | + edge="end" |
| 276 | + aria-controls={profileMenuId} |
| 277 | + aria-haspopup="true" |
| 278 | + aria-expanded={isProfileMenuOpen ? 'true' : undefined} |
| 279 | + onClick={handleProfileMenuOpen} |
302 | 280 | >
|
303 |
| - {profiles.map((profile) => ( |
304 |
| - <MenuItem key={profile} color="inherit" onClick={() => { router.push(`/admin/${profile}`); }}>{profile}</MenuItem> |
305 |
| - ))} |
306 |
| - <Divider /> |
307 |
| - <MenuItem color="inherit" onClick={() => { setAddProfileDialogOpened(true);}}>Add</MenuItem> |
308 |
| - </Menu> |
309 |
| - <Menu |
310 |
| - id={userMenuId} |
311 |
| - anchorEl={userAnchorEl} |
312 |
| - open={isUserMenuOpen} |
313 |
| - onClose={handleUserMenuClose} |
| 281 | + <WidgetsIcon /> |
| 282 | + </IconButton> |
| 283 | + <IconButton |
| 284 | + size="large" |
| 285 | + color="inherit" |
| 286 | + onClick={()=>{setAddWidgetDialogOpened(true);}} |
314 | 287 | >
|
315 |
| - <MenuItem color="inherit" onClick={signout}>Logout</MenuItem> |
316 |
| - </Menu> |
317 |
| - <AddProfileDialog |
318 |
| - open={addProfileDialogOpened} |
319 |
| - onClose={() => { |
320 |
| - setAddProfileDialogOpened(false); |
321 |
| - }} |
322 |
| - /> |
323 |
| - <AddWidgetDialog |
324 |
| - profile={currentProfile} |
325 |
| - open={addWidgetDialogOpened} |
326 |
| - onClose={() => { |
327 |
| - setAddWidgetDialogOpened(false); |
328 |
| - }} |
329 |
| - /> |
| 288 | + <AddIcon /> |
| 289 | + </IconButton> |
| 290 | + <IconButton |
| 291 | + size="large" |
| 292 | + color="inherit" |
| 293 | + edge="end" |
| 294 | + aria-controls={userMenuId} |
| 295 | + aria-haspopup="true" |
| 296 | + aria-expanded={isUserMenuOpen ? 'true' : undefined} |
| 297 | + onClick={handleUserMenuOpen} |
| 298 | + > |
| 299 | + <AccountCircleIcon /> |
| 300 | + </IconButton> |
| 301 | + </Box> |
| 302 | + </Toolbar> |
| 303 | + </AppBar> |
| 304 | + <Menu |
| 305 | + id={profileMenuId} |
| 306 | + anchorEl={profileAnchorEl} |
| 307 | + open={isProfileMenuOpen} |
| 308 | + onClose={handleProfileMenuClose} |
| 309 | + > |
| 310 | + {profiles.map((profile) => ( |
| 311 | + <MenuItem key={profile} color="inherit" onClick={() => { router.push(`/admin/${profile}`); }}>{profile}</MenuItem> |
| 312 | + ))} |
| 313 | + <Divider /> |
| 314 | + <MenuItem color="inherit" onClick={() => { setAddProfileDialogOpened(true);}}>Add</MenuItem> |
| 315 | + </Menu> |
| 316 | + <Menu |
| 317 | + id={userMenuId} |
| 318 | + anchorEl={userAnchorEl} |
| 319 | + open={isUserMenuOpen} |
| 320 | + onClose={handleUserMenuClose} |
| 321 | + > |
| 322 | + <MenuItem color="inherit" onClick={signout}>Logout</MenuItem> |
| 323 | + </Menu> |
| 324 | + <AddProfileDialog |
| 325 | + open={addProfileDialogOpened} |
| 326 | + onClose={() => { |
| 327 | + setAddProfileDialogOpened(false); |
| 328 | + }} |
| 329 | + /> |
| 330 | + <AddWidgetDialog |
| 331 | + profile={currentProfile} |
| 332 | + open={addWidgetDialogOpened} |
| 333 | + onClose={() => { |
| 334 | + setAddWidgetDialogOpened(false); |
| 335 | + }} |
| 336 | + /> |
330 | 337 |
|
331 |
| - <Container className={classes.content}> |
332 |
| - <Box my={4}> |
333 |
| - <Widgets profile={currentProfile} /> |
334 |
| - </Box> |
335 |
| - </Container> |
| 338 | +<Container className={classes.content}> |
| 339 | + <Box my={4}> |
| 340 | + <Widgets profile={currentProfile} /> |
| 341 | + </Box> |
| 342 | +</Container> |
336 | 343 | </div>
|
337 | 344 | </AuthProvider>
|
338 | 345 | ) : (
|
339 | 346 | <Signin />
|
340 |
| - ); |
| 347 | + )} |
| 348 | +</>) |
| 349 | +; |
341 | 350 | };
|
342 | 351 |
|
343 | 352 | export default AdminIndexPage;
|
0 commit comments