From 5fa2e7a473180def1bfcc529fb528e9555a133bb Mon Sep 17 00:00:00 2001 From: Sabrina Kuah Date: Fri, 16 Apr 2021 02:17:49 -0700 Subject: [PATCH] Disable drawer nav links, #116 --- client/src/components/DrawerNav.js | 194 ++++++++++++++--------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/client/src/components/DrawerNav.js b/client/src/components/DrawerNav.js index 39c52c6..a3afc1e 100644 --- a/client/src/components/DrawerNav.js +++ b/client/src/components/DrawerNav.js @@ -1,5 +1,5 @@ -import React, { useState } from "react" -import { Link } from "react-router-dom" +import React, { useState } from 'react'; +import { Link } from 'react-router-dom'; import { Divider, CssBaseline, @@ -21,84 +21,84 @@ import { TextField, DialogActions, Button, -} from "@material-ui/core" -import { makeStyles, useTheme } from "@material-ui/core/styles" -import MenuIcon from "@material-ui/icons/Menu" -import DashboardIcon from "@material-ui/icons/Dashboard" -import QuestionAnswerIcon from "@material-ui/icons/QuestionAnswer" -import ChatIcon from "@material-ui/icons/Chat" -import WarningIcon from "@material-ui/icons/Warning" -import SettingsIcon from "@material-ui/icons/Settings" -import NotificationsActiveIcon from "@material-ui/icons/NotificationsActive" -import ExpandMoreIcon from "@material-ui/icons/ExpandMore" -import ExitToAppIcon from "@material-ui/icons/ExitToApp" -import DeleteIcon from "@material-ui/icons/Delete" -import Dashboard from "../views/dashboard/Dashboard" -import { logoutUser, updateAvatar } from "../network/user" -import { useHistory } from "react-router-dom" -import useLocalStorage from "react-use-localstorage" -import toastr from "toastr" +} from '@material-ui/core'; +import { makeStyles, useTheme } from '@material-ui/core/styles'; +import MenuIcon from '@material-ui/icons/Menu'; +import DashboardIcon from '@material-ui/icons/Dashboard'; +import QuestionAnswerIcon from '@material-ui/icons/QuestionAnswer'; +import ChatIcon from '@material-ui/icons/Chat'; +import WarningIcon from '@material-ui/icons/Warning'; +import SettingsIcon from '@material-ui/icons/Settings'; +import NotificationsActiveIcon from '@material-ui/icons/NotificationsActive'; +import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import ExitToAppIcon from '@material-ui/icons/ExitToApp'; +import DeleteIcon from '@material-ui/icons/Delete'; +import Dashboard from '../views/dashboard/Dashboard'; +import { logoutUser, updateAvatar } from '../network/user'; +import { useHistory } from 'react-router-dom'; +import useLocalStorage from 'react-use-localstorage'; +import toastr from 'toastr'; -const drawerWidth = 240 +const drawerWidth = 240; function DrawerNav({ window, user, children }) { - const classes = useStyles() - const theme = useTheme() - const [mobileOpen, setMobileOpen] = useState(false) - const [avatarOpen, setAvatarOpen] = useState(false) - const [avatarUrl, setAvatarUrl] = useState(user?.avatar ? user.avatar : "") - const history = useHistory() - const [token, setToken] = useLocalStorage("token", "") + const classes = useStyles(); + const theme = useTheme(); + const [mobileOpen, setMobileOpen] = useState(false); + const [avatarOpen, setAvatarOpen] = useState(false); + const [avatarUrl, setAvatarUrl] = useState(user?.avatar ? user.avatar : ''); + const history = useHistory(); + const [token, setToken] = useLocalStorage('token', ''); const handleDrawerToggle = () => { - setMobileOpen(!mobileOpen) - } + setMobileOpen(!mobileOpen); + }; const handleLogout = async () => { - const response = await logoutUser() - toastr["success"](response.data.message) + const response = await logoutUser(); + toastr['success'](response.data.message); // alert(response.data.message); - setToken("") + setToken(''); //should setUser(null) - history.replace("/") - } + history.replace('/'); + }; const handleAvatarSave = async () => { const avatar = { avatar: avatarUrl, - } - const response = await updateAvatar({ token, avatar }) + }; + const response = await updateAvatar({ token, avatar }); response.message - ? toastr["success"](response.message) - : toastr["error"](response.error) + ? toastr['success'](response.message) + : toastr['error'](response.error); //call getUser here - setAvatarOpen(false) - } + setAvatarOpen(false); + }; const drawer = (
{/*
*/} -
-
+
+
{ - setAvatarOpen(true) + setAvatarOpen(true); }} />
-
+
-
+
{user?.firstName} {user?.lastName}
-

{user?.email}

+

{user?.email}

- + setAvatarOpen(true)}> @@ -106,15 +106,15 @@ function DrawerNav({ window, user, children }) {
- + - + - + - + {/* @@ -131,60 +131,60 @@ function DrawerNav({ window, user, children }) { - + */} - + setAvatarOpen(true)}> - + - + - + - + - + - +
- ) + ); const container = - window !== undefined ? () => window().document.body : undefined + window !== undefined ? () => window().document.body : undefined; return (
- + - -