Home.js 25.4 KB
Newer Older
d.arizona's avatar
d.arizona committed
1
import React from 'react';
d.arizona's avatar
d.arizona committed
2 3 4 5 6 7 8 9 10 11
import clsx from 'clsx';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import List from '@material-ui/core/List';
import CssBaseline from '@material-ui/core/CssBaseline';
import Typography from '@material-ui/core/Typography';
import Divider from '@material-ui/core/Divider';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
d.arizona's avatar
d.arizona committed
12 13
import ExpandMore from '@material-ui/icons/ExpandMore'
import ExpandLess from '@material-ui/icons/ExpandLess'
14
import Announcement from '@material-ui/icons/Announcement';
d.arizona's avatar
d.arizona committed
15 16
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
d.arizona's avatar
d.arizona committed
17
import Collapse from '@material-ui/core/Collapse';
d.arizona's avatar
d.arizona committed
18
import DateFnsUtils from '@date-io/date-fns';
d.arizona's avatar
d.arizona committed
19
import { MuiPickersUtilsProvider } from "@material-ui/pickers";
Deni Rinaldi's avatar
Deni Rinaldi committed
20
import localeID from 'date-fns/locale/en-US';
Deni Rinaldi's avatar
Deni Rinaldi committed
21
import ReactTooltip from 'react-tooltip';
d.arizona's avatar
d.arizona committed
22

d.arizona's avatar
d.arizona committed
23
import {
Deni Rinaldi's avatar
Deni Rinaldi committed
24 25 26
  Switch,
  Route,
  Link,
d.arizona's avatar
d.arizona committed
27
  useRouteMatch, useLocation
Deni Rinaldi's avatar
Deni Rinaldi committed
28
} from "react-router-dom";
syadziy's avatar
syadziy committed
29
import Images from '../../assets/Images';
syadziy's avatar
syadziy committed
30
import { UseWindowDimensions } from '../../utils/index';
syadziy's avatar
syadziy committed
31 32 33
import HomeRoutes from '../../router/homeRoutes'
import Constant from '../../library/Constant';
import api from '../../api';
d.arizona's avatar
d.arizona committed
34

Deni Rinaldi's avatar
Deni Rinaldi committed
35
const drawerWidth = 307;
d.arizona's avatar
d.arizona committed
36

d.arizona's avatar
d.arizona committed
37
const useStyles = makeStyles((theme) => ({
d.arizona's avatar
d.arizona committed
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
  root: {
    display: 'flex',
  },
  appBar: {
    zIndex: theme.zIndex.drawer + 1,
    transition: theme.transitions.create(['width', 'margin'], {
      easing: theme.transitions.easing.sharp,
      duration: theme.transitions.duration.leavingScreen,
    }),
  },
  appBarShift: {
    marginLeft: drawerWidth,
    width: `calc(100% - ${drawerWidth}px)`,
    transition: theme.transitions.create(['width', 'margin'], {
      easing: theme.transitions.easing.sharp,
      duration: theme.transitions.duration.enteringScreen,
    }),
  },
  menuButton: {
    marginRight: 36,
  },
  hide: {
    display: 'none',
  },
  drawer: {
    width: drawerWidth,
    flexShrink: 0,
    whiteSpace: 'nowrap',
  },
d.arizona's avatar
d.arizona committed
67 68 69 70 71 72 73
  topleftOpen: {
    width: drawerWidth,
    borderRight: 0,
    transition: theme.transitions.create('width', {
      easing: theme.transitions.easing.sharp,
      duration: theme.transitions.duration.enteringScreen,
    }),
Deni Rinaldi's avatar
Deni Rinaldi committed
74
    backgroundColor: '#273b80'
d.arizona's avatar
d.arizona committed
75 76 77 78 79 80 81 82 83 84 85 86 87
  },
  topleftClose: {
    borderRight: 0,
    transition: theme.transitions.create('width', {
      easing: theme.transitions.easing.sharp,
      duration: theme.transitions.duration.leavingScreen,
    }),
    overflowX: 'hidden',
    width: theme.spacing(3) + 2,
    height: '78px',
    [theme.breakpoints.up('sm')]: {
      width: theme.spacing(7) + 1,
    },
Deni Rinaldi's avatar
Deni Rinaldi committed
88 89
    padding: 20,
    display: 'flex',
Deni Rinaldi's avatar
Deni Rinaldi committed
90
    backgroundColor: '#273b80'
d.arizona's avatar
d.arizona committed
91
  },
d.arizona's avatar
d.arizona committed
92 93
  drawerOpen: {
    width: drawerWidth,
Deni Rinaldi's avatar
Deni Rinaldi committed
94
    borderRight: 0,
d.arizona's avatar
d.arizona committed
95 96 97 98
    transition: theme.transitions.create('width', {
      easing: theme.transitions.easing.sharp,
      duration: theme.transitions.duration.enteringScreen,
    }),
d.arizona's avatar
d.arizona committed
99
    backgroundColor: '#f6f7f9',
d.arizona's avatar
d.arizona committed
100 101
  },
  drawerClose: {
Deni Rinaldi's avatar
Deni Rinaldi committed
102
    borderRight: 0,
d.arizona's avatar
d.arizona committed
103 104 105 106 107
    transition: theme.transitions.create('width', {
      easing: theme.transitions.easing.sharp,
      duration: theme.transitions.duration.leavingScreen,
    }),
    overflowX: 'hidden',
Deni Rinaldi's avatar
Deni Rinaldi committed
108
    width: theme.spacing(3) + 2,
d.arizona's avatar
d.arizona committed
109
    [theme.breakpoints.up('sm')]: {
Deni Rinaldi's avatar
Deni Rinaldi committed
110
      width: theme.spacing(7) + 1,
d.arizona's avatar
d.arizona committed
111
    },
d.arizona's avatar
d.arizona committed
112
    backgroundColor: '#f6f7f9',
d.arizona's avatar
d.arizona committed
113 114 115 116 117 118 119 120 121
  },
  toolbar: {
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'flex-end',
    padding: theme.spacing(0, 1),
    // necessary for content to be below app bar
    ...theme.mixins.toolbar,
  },
Deni Rinaldi's avatar
Deni Rinaldi committed
122 123 124 125 126 127 128
  toolbarDrawer: {
    alignItems: 'center',
    justifyContent: 'flex-end',
    padding: theme.spacing(0, 1),
    // necessary for content to be below app bar
    // ...theme.mixins.toolbar
  },
d.arizona's avatar
d.arizona committed
129 130 131 132
  content: {
    flexGrow: 1,
    padding: theme.spacing(3),
  },
Deni Rinaldi's avatar
Deni Rinaldi committed
133 134 135 136 137
  orangeAvatar: {
    margin: 10,
    color: '#fff',
    backgroundColor: 'black',
  },
d.arizona's avatar
d.arizona committed
138 139
}));

d.arizona's avatar
d.arizona committed
140
export default function MiniDrawer() {
d.arizona's avatar
d.arizona committed
141
  let location = useLocation();
d.arizona's avatar
d.arizona committed
142 143 144
  const classes = useStyles();
  const theme = useTheme();
  const [open, setOpen] = React.useState(false);
d.arizona's avatar
d.arizona committed
145
  const [selectedIndex, setSelectedIndex] = React.useState([]);
Deni Rinaldi's avatar
Deni Rinaldi committed
146 147
  const [selectedIndexs, setSelectedIndexs] = React.useState([]);
  const [selectedSubIndex, setSelectSub] = React.useState([]);
d.arizona's avatar
d.arizona committed
148 149
  const [userFullname, setUserFullname] = React.useState("")
  const [userEmail, setUserEmail] = React.useState("")
150
  const [userPhoto, setUserPhoto] = React.useState("")
151 152
  const [application, setApplication] = React.useState([])
  const [setting, setSetting] = React.useState([])
153 154
  const [isApprover, setIsApprover] = React.useState(false);

d.arizona's avatar
d.arizona committed
155 156 157
  const [data, setData] = React.useState({
    array: [
      {
158 159 160 161 162
        img: Images.Home,
        label: 'Home',
        path: 'beranda',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
163 164
      },
      {
165 166 167 168 169
        img: Images.budgetTahunan,
        label: 'Master Budget & CAT',
        path: 'budget-tahunan',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
170 171
      },
      {
172 173 174 175 176
        img: Images.laporanBulanan,
        label: 'Monthly Report',
        path: 'beranda',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
177 178
      },
      {
179 180 181 182 183
        img: Images.rolling,
        label: 'Rolling Outlook & CAT Revision',
        path: 'beranda',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
184 185
      },
      {
186 187 188 189 190
        img: Images.outlookperformance,
        label: 'Outlook Performance Appraisal',
        path: 'beranda',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
191 192
      },
      {
193 194 195 196 197
        img: Images.operatingindicator,
        label: 'Operating Indicator',
        path: 'beranda',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
198 199
      },
      {
200 201 202 203 204
        img: Images.manajemenDokumen,
        label: 'Document Management',
        path: 'beranda',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
205 206
      },
      {
207 208 209 210 211
        img: Images.laporan,
        label: 'Reports',
        path: '',
        subItem: [
          {
d.arizona's avatar
d.arizona committed
212 213 214 215
            img: '',
            label: 'Subco',
            path: 'beranda',
          }, {
216
            img: 'beranda',
d.arizona's avatar
d.arizona committed
217 218 219
            label: 'Summary of Triputra Group',
            path: 'beranda',
          }, {
d.arizona's avatar
d.arizona committed
220 221 222
            img: 'beranda',
            label: 'Financial Dashboard',
            path: 'dashboard-financial',
d.arizona's avatar
d.arizona committed
223
          }, {
224
            img: 'beranda',
d.arizona's avatar
d.arizona committed
225
            label: 'CAT Dashboard',
d.arizona's avatar
d.arizona committed
226
            path: 'cat-dashboard',
227 228 229
          }
        ],
        collapse: false,
d.arizona's avatar
d.arizona committed
230 231
      },
      {
232 233 234 235 236
        img: '',
        label: 'Settings',
        path: 'beranda',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
237
      },
qorri_di's avatar
qorri_di committed
238 239 240 241 242 243 244 245 246 247 248 249 250
      {
        img: Images.masterdata,
        label: 'General Setting',
        path: '',
        subItem: [
          {
            img: '',
            label: 'Maintenance Mode',
            path: 'maintenance-mode',
          },
        ],
        collapse: false,
      },
d.arizona's avatar
d.arizona committed
251
      {
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
        img: Images.masterdata,
        label: 'Master Data',
        path: '',
        subItem: [
          {
            img: '',
            label: 'Business Unit',
            path: 'unit-bisnis',
          },
          {
            img: '',
            label: 'Company',
            path: 'perusahaan',
          },
          {
            img: '',
            label: 'Report Items',
            path: 'report-items',
          },
          {
            img: '',
            label: 'Parameters',
            path: 'parameter',
          },
        ],
        collapse: false,
d.arizona's avatar
d.arizona committed
278 279
      },
      {
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
        img: Images.otorisasi,
        label: 'Authorization',
        path: '',
        subItem: [
          {
            img: '',
            label: 'User Role',
            path: 'userrole',
          },
          {
            img: '',
            label: 'User',
            path: 'user',
          }
        ],
        collapse: false,
d.arizona's avatar
d.arizona committed
296 297
      },
      {
298 299 300 301 302
        img: Images.approvalmatrix,
        label: 'Approval Matrix',
        path: 'approval-matrix',
        subItem: null,
        collapse: false,
d.arizona's avatar
d.arizona committed
303 304
      },
      {
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
        img: Images.otorisasi,
        label: 'User Management',
        path: '',
        subItem: [
          {
            img: '',
            label: 'Profile',
            path: 'profile',
          },
          {
            img: '',
            label: 'Logout',
            path: '',
          },
        ],
        collapse: false,
d.arizona's avatar
d.arizona committed
321
      }
322
    ]
d.arizona's avatar
d.arizona committed
323
  })
324

d.arizona's avatar
d.arizona committed
325
  React.useEffect(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
326
    if (userFullname === "" && userEmail === "") {
d.arizona's avatar
d.arizona committed
327
      getUserData()
d.arizona's avatar
d.arizona committed
328
      getMenuHierarki()
329
      getDetailUser()
330
    }
d.arizona's avatar
d.arizona committed
331
  })
d.arizona's avatar
d.arizona committed
332

333 334
  const parseChildren = (val) => {
    let data = Object.assign([], val)
335
    data = data.sort((a, b) => a.menu_id - b.menu_id).map((i) => {
336 337 338 339 340 341 342 343 344 345 346
      return {
        img: i.icon === '#' ? "" : i.icon,
        label: i.menu_name,
        path: i.url,
        subItem: parseChildren(i.sub_menu),
        collapse: false
      }
    })
    return data
  }

347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
  const getDetailUser = () => {
    let userId = localStorage.getItem(Constant.USER)
    api.create().getDetailUser(userId).then((response) => {
      if (response.data) {
        if (response.ok) {
          if (response.data.status === 'success') {
            getRole(response.data.data.role_id)
          }
        }
      }
    })
  }

  const getRole = (id) => {
    api.create().getDetailRole(id).then((response) => {
qorri_di's avatar
qorri_di committed
362
      // console.log(response)
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
      if (response.data.status === 'success') {
        // this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
        // // // console.log(response.data.data)
        if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
          getIsApprover(true)
        } else {
          getIsApprover(false)
        }
      } else {
        getIsApprover(false)
      }
    })
  }

  const getIsApprover = (superadmin) => {
    api.create().getAM().then((response) => {
qorri_di's avatar
qorri_di committed
379
      // console.log(response);
380 381 382 383 384 385 386 387 388
      let actAMActive = response.data.data
      let userId = localStorage.getItem(Constant.USER)
      let indexId = actAMActive.findIndex((val) => val.user_id == userId)
      if (indexId != -1 || superadmin) {
        setIsApprover(true)
      }
    })
  }

d.arizona's avatar
d.arizona committed
389 390
  const getMenuHierarki = () => {
    api.create().getMenuByRole().then((response) => {
qorri_di's avatar
qorri_di committed
391
      // console.log(response)
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
      if (response.data) {
        if (response.data.status === "success") {
          let app = null
          let set = null
          response.data.data.map((item) => {
            if (item.menu_name === "Application") {
              app = parseChildren(item.sub_menu)
              return app
            } else {
              set = parseChildren(item.sub_menu)
              return set
            }
          })
          setApplication(app)
          setSetting(set)
        } else {
          localStorage.removeItem(Constant.TOKEN)
          window.location.reload();
        }
411 412 413 414
      } else {
        localStorage.removeItem(Constant.TOKEN)
        window.location.reload();
      }
d.arizona's avatar
d.arizona committed
415 416 417
    })
  }

d.arizona's avatar
d.arizona committed
418 419 420
  const getUserData = () => {
    let userId = localStorage.getItem(Constant.USER)
    api.create().getDetailUser(userId).then((response) => {
421
      if (response.data) {
Deni Rinaldi's avatar
Deni Rinaldi committed
422
        if (response.data.status === 'success') {
423 424 425 426
          setUserFullname(response.data.data.fullname === null ? 'Anonym' : response.data.data.fullname)
          setUserEmail(response.data.data.email === null ? 'Anonym@123.xyz' : response.data.data.email)
          setUserPhoto(response.data.data.photo === null ? "" : response.data.data.photo)
        }
d.arizona's avatar
d.arizona committed
427 428 429
      }
    })
  }
d.arizona's avatar
d.arizona committed
430

431
  const logout = () => {
d.arizona's avatar
d.arizona committed
432 433 434 435
    localStorage.removeItem(Constant.TOKEN)
    window.location.reload();
  }

d.arizona's avatar
d.arizona committed
436 437
  const handleDrawerOpen = () => {
    setOpen(true);
d.arizona's avatar
d.arizona committed
438 439
  };

d.arizona's avatar
d.arizona committed
440 441
  const handleDrawerClose = () => {
    setOpen(false);
d.arizona's avatar
d.arizona committed
442 443
  };

Deni Rinaldi's avatar
Deni Rinaldi committed
444 445 446 447 448 449
  const resetIndex = () => {
    setSelectedIndex("")
    setSelectedIndexs("")
  }

  const selectSub = (e) => {
d.arizona's avatar
d.arizona committed
450
    setOpen(true)
Deni Rinaldi's avatar
Deni Rinaldi committed
451 452 453 454 455 456 457
    setSelectSub(e)
    setSelectedIndex("")
  }

  const selectIndex = (e) => {
    setSelectSub("")
    setSelectedIndex(e)
d.arizona's avatar
d.arizona committed
458
    // alert(e)
Deni Rinaldi's avatar
Deni Rinaldi committed
459
    // if (open === false) {
Deni Rinaldi's avatar
Deni Rinaldi committed
460
    // setOpen(true)
d.arizona's avatar
d.arizona committed
461
    // }
Deni Rinaldi's avatar
Deni Rinaldi committed
462 463
  }

d.arizona's avatar
d.arizona committed
464
  let { path, url } = useRouteMatch();
d.arizona's avatar
d.arizona committed
465

Deni Rinaldi's avatar
Deni Rinaldi committed
466 467
  const { height, width } = UseWindowDimensions();

468
  function handleCollapse(item) {
d.arizona's avatar
d.arizona committed
469
    setOpen(true);
470 471 472 473 474 475 476
    let arr = application
    let index = arr.findIndex((val) => val.label === item.label)
    arr[index].collapse = !arr[index].collapse
    setData({ ...application, application: arr })
  }

  function handleCollapseSetting(item) {
d.arizona's avatar
d.arizona committed
477
    setOpen(true);
478
    let arr = setting
d.arizona's avatar
d.arizona committed
479 480
    let index = arr.findIndex((val) => val.label === item.label)
    arr[index].collapse = !arr[index].collapse
481
    setData({ ...setting, setting: arr })
d.arizona's avatar
d.arizona committed
482 483
  }

d.arizona's avatar
d.arizona committed
484
  return (
qorri_di's avatar
qorri_di committed
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
    <div className={classes.root}>
      <CssBaseline />
      <AppBar
        position="fixed"
        className={clsx(classes.appBar, {
          [classes.appBarShift]: open,
        })}
      >
      </AppBar>
      <Drawer
        variant="permanent"
        className={clsx(classes.drawer, {
          [classes.drawerOpen]: open,
          [classes.drawerClose]: !open,
        })}
        classes={{
          paper: clsx({
            [classes.drawerOpen]: open,
            [classes.drawerClose]: !open,
          }),
        }}
      >
        <div className={clsx(classes.drawer, {
          [classes.topleftOpen]: open,
          [classes.topleftClose]: !open,
        })}
          classes={{
            paper: clsx({
              [classes.topleftOpen]: open,
              [classes.topleftClose]: !open,
            }),
          }}>
          {open === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
518

qorri_di's avatar
qorri_di committed
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
            <div style={{ display: 'flex', justifyContent: 'space-between', flex: 1, padding: 10 }}>
              <img src={Images.triputra} alt="React Logo" style={{ height: 31, width: 151, alignSelf: 'center', marginLeft: 5 }} />
              <IconButton onClick={handleDrawerClose} style={{ outline: 'none' }}>
                <MenuIcon style={{ fill: 'white' }} />
              </IconButton>
            </div> :
            <IconButton
              color="inherit"
              aria-label="open drawer"
              style={{ outline: 'none' }}
              onClick={handleDrawerOpen}
              edge="start"
              className={clsx(classes.menuButton, {
                [classes.hide]: open,
              })}
            >
Deni Rinaldi's avatar
Deni Rinaldi committed
535

qorri_di's avatar
qorri_di committed
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
              <a data-tip={"Main Menu"} data-for={"main-menu"}>
                <MenuIcon style={{ fill: 'white', alignSelf: 'center' }} />
              </a>
              <ReactTooltip border={true} id={"main-menu"} place="bottom" type="light" effect="solid" />
            </IconButton>}
          {open &&
            <div style={{ width: '100%', marginTop: 15, marginBottom: 60 }}>
              <Link to={"profile"}>
                <Typography style={{ fontSize: 14, color: '#fff', textAlign: 'center', fontWeight: 'bold' }}>{userFullname}</Typography>
              </Link>
              <Link to={"profile"}>
                <Typography style={{ fontSize: 14, color: '#fff', textAlign: 'center', marginTop: 10 }}>{userEmail}</Typography>
              </Link>
            </div>
          }
        </div>
        <Divider />
        {open &&
          <div style={{ width: '100%', textAlign: '-webkit-center', marginTop: -45, display: 'flex', justifyContent: 'center' }}>
            <Link to={"profile"}>
              <div className={"sub-color"} style={{ width: 90, height: 90, borderRadius: 50, display: 'flex', justifyContent: 'center' }}>
                <div style={{ width: 72, height: 72, backgroundColor: '#838383', borderRadius: 50, alignSelf: 'center' }}>
                  {userPhoto === "" ? null : <img src={userPhoto} style={{ width: 72, height: 72, borderRadius: 50 }} />}
Deni Rinaldi's avatar
Deni Rinaldi committed
559
                </div>
qorri_di's avatar
qorri_di committed
560 561
              </div>
            </Link>
d.arizona's avatar
d.arizona committed
562
          </div>
qorri_di's avatar
qorri_di committed
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
        }
        {open && application.length > 0 &&
          <div style={{ marginLeft: 20, marginTop: 10 }}>
            <Typography style={{ color: '#525355', fontSize: 14, fontFamily: 'Nunito Sans, sans-serif' }}>Application</Typography>
          </div>
        }
        <List>
          {application.map((item, index) => (
            <div style={{ marginTop: index === 0 ? null : 5 }} >
              {item.subItem.length !== 0 ?
                <a data-tip={item.label} data-for={item.label}>
                  <div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10, cursor: 'pointer' }} onClick={() => { handleCollapse(item) }}>
                    <ListItem key={item.label}>
                      <ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon>
                      <Typography style={{ fontFamily: 'Nunito Sans, sans-serif', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
                    </ListItem>
                    {item.subItem.length !== 0 ? (item.collapse ? <ExpandLess style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} /> : <ExpandMore style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} />) : null}
                    {!open && (<ReactTooltip border={true} id={item.label} place="bottom" type="light" effect="solid" />)}
                  </div>
                </a>
                :
                <Link to={`${url}/${item.path}`}>
                  <div style={{ paddingLeft: 5 }} className={selectedIndex === item.label ? "active" : ""}>
                    <a data-tip={item.label} data-for={item.label}>
                      <ListItem button key={item.label} onClick={() => selectIndex(item.label)}>
                        <ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} style={{ fill: '#525355' }} /></ListItemIcon>
                        <Typography style={{ fontFamily: 'Nunito Sans, sans-serif', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
                      </ListItem>
                    </a>
                    {!open && (<ReactTooltip border={true} id={item.label} place="bottom" type="light" effect="solid" />)}
593 594
                  </div>
                </Link>
qorri_di's avatar
qorri_di committed
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
              }
              {item.subItem.length !== 0 &&
                <div>
                  <Collapse in={item.collapse} timeout="auto" unmountOnExit>
                    <List component="div" disablePadding>
                      {item.subItem.map((sub, indexs) => {
                        return (
                          <Link to={sub.label === "Logout" ? `/` : `${url}/${sub.path}`}>
                            <a data-tip={sub.label} data-for={sub.label}>
                              <div style={{ paddingLeft: 5, }} className={selectedSubIndex === sub.label ? "active" : ""} onClick={() => sub.label === "Logout" ? logout() : selectSub(sub.label)}>
                                <ListItem button style={{ paddingLeft: 57 }}>
                                  <Typography style={{ fontFamily: 'Nunito Sans, sans-serif', color: '#525355', fontSize: 14 }}>{sub.label}</Typography>
                                </ListItem>
                              </div>
                            </a>
                            {!open && (<ReactTooltip border={true} id={sub.label} place="bottom" type="light" effect="solid" />)}
                          </Link>
                        )
                      })}
                    </List>
                  </Collapse>
616
                </div>
qorri_di's avatar
qorri_di committed
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
              }
            </div>
          ))}
          {isApprover && <Link to={`${url}/progress-reports`}>
            <div style={{ paddingLeft: 5 }} className={selectedIndex === 'Progress Report' ? "active" : ""}>
              <a data-tip={'Progress Report'} data-for={'Progress Report'}>
                <ListItem button key={'progress-reports'} onClick={() => selectIndex('Progress Report')}>
                  <ListItemIcon style={{ minWidth: open ? 40 : 56 }}><Announcement style={{ marginLeft: -5 }} /></ListItemIcon>
                  <Typography style={{ fontFamily: 'Nunito Sans, sans-serif', color: '#525355', fontSize: 14 }}>{'Progress Report'}</Typography>
                </ListItem>
              </a>
              {!open && (<ReactTooltip border={true} id={'Progress Report'} place="bottom" type="light" effect="solid" />)}
            </div>
          </Link>}
        </List>
        {open && setting.length > 0 &&
          <div style={{ marginLeft: 20 }}>
            <Typography style={{ color: '#525355', fontSize: 14, fontFamily: 'Nunito Sans, sans-serif' }}>Setting</Typography>
          </div>
        }
        <List style={{ marginTop: !open ? -10 : null, marginLeft: !open ? -2 : null }}>
          {setting.map((item, index) => (
            <div style={{ marginTop: index === 0 ? null : 5 }} >
              {item.subItem.length !== 0 ?
                <a data-tip={item.label} data-for={item.label}>
                  <div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10, cursor: 'pointer' }} onClick={() => { handleCollapseSetting(item) }}>
                    <ListItem key={item.label}>
                      <ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon>
                      <Typography style={{ fontFamily: 'Nunito Sans, sans-serif', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
                    </ListItem>
                    {item.subItem.length !== 0 ? (item.collapse ? <ExpandLess style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} /> : <ExpandMore style={{ color: "#525355", marginLeft: 50, alignSelf: 'center' }} />) : null}
                    {!open && (<ReactTooltip border={true} id={item.label} place="bottom" type="light" effect="solid" />)}
                  </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
650
                </a>
qorri_di's avatar
qorri_di committed
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
                :
                <Link to={`${url}/${item.path}`}>
                  <div style={{ paddingLeft: 5 }} className={selectedIndex === item.label ? "active" : ""}>
                    <a data-tip={item.label} data-for={item.label}>
                      <ListItem button key={item.label} onClick={() => selectIndex(item.label)}>
                        <ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} style={{ fill: '#525355' }} /></ListItemIcon>
                        <Typography style={{ fontFamily: 'Nunito Sans, sans-serif', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
                      </ListItem>
                    </a>
                    {!open && (<ReactTooltip border={true} id={item.label} place="bottom" type="light" effect="solid" />)}
                  </div>
                </Link>
              }
              {item.subItem.length !== 0 &&
                <div>
                  <Collapse in={item.collapse} timeout="auto" unmountOnExit>
                    <List component="div" disablePadding>
                      {item.subItem.map((sub, indexs) => {
                        return (
                          <Link to={sub.label === "Logout" ? `/` : `${url}/${sub.path}`}>
                            <a data-tip={sub.label} data-for={sub.label}>
                              <div style={{ paddingLeft: 5, }} className={selectedSubIndex === sub.label ? "active" : ""} onClick={() => sub.label === "Logout" ? logout() : selectSub(sub.label)}>
                                <ListItem button style={{ paddingLeft: 57 }}>
                                  <Typography style={{ fontFamily: 'Nunito Sans, sans-serif', color: '#525355', fontSize: 14 }}>{sub.label}</Typography>
                                </ListItem>
                              </div>
                            </a>
                            {!open && (<ReactTooltip border={true} id={sub.label} place="bottom" type="light" effect="solid" />)}
                          </Link>
                        )
                      })}
                    </List>
                  </Collapse>
d.arizona's avatar
d.arizona committed
684
                </div>
qorri_di's avatar
qorri_di committed
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
              }
            </div>
          ))}
        </List>
        {open &&
          <div style={{ marginLeft: 20, marginTop: 5, paddingBottom: 20 }}>
            <button
              style={{
                outline: 'none',
                backgroundColor: 'transparent',
                cursor: 'pointer',
                borderColor: 'transparent',
              }}
              onClick={() => logout()}>
              <Typography style={{ color: '#525355', fontSize: 14, fontFamily: 'Nunito Sans, sans-serif' }}>Logout</Typography>
            </button>
          </div>
        }
      </Drawer>
      <div className={classes.content} style={{ justifyContent: 'space-between', padding: 0, backgroundColor: '#f8f8f8' }}>
        <div>
          {/* <div className={classes.toolbar} /> */}
          <MuiPickersUtilsProvider locale={localeID} utils={DateFnsUtils}>
            <Switch>
              {HomeRoutes.map((route, index) => (
                // You can render a <Route> in as many places
                // as you want in your app. It will render along
                // with any other <Route>s that also match the URL.
                // So, a sidebar or breadcrumbs or anything else
                // that requires you to render multiple things
                // in multiple places at the same URL is nothing
                // more than multiple <Route>s.
                <Route
                  key={index}
                  path={route.path}
                  // exact={route.exact}
                  location={location}
                  children={<route.main height={height} width={width} open={open} location={location} selectIndex={selectIndex.bind(this)} />}
                />
              ))}
            </Switch>
          </MuiPickersUtilsProvider>
          {/* <Footer>
Deni Rinaldi's avatar
Deni Rinaldi committed
728
            <Typography style={{ fontSize: '12px' }}>© EKSAD Technology. All rights reserved.</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
729
          </Footer> */}
qorri_di's avatar
qorri_di committed
730
        </div>
qorri_di's avatar
qorri_di committed
731

Deni Rinaldi's avatar
Deni Rinaldi committed
732
      </div>
qorri_di's avatar
qorri_di committed
733
    </div>
d.arizona's avatar
d.arizona committed
734 735
  );
}