| @@ -85,6 +85,15 @@ export const isUserLoggedIn = () => { | |||||
| export const getUserData = () => JSON.parse(localStorage.getItem('userData')); | export const getUserData = () => JSON.parse(localStorage.getItem('userData')); | ||||
| export const checkAuth = (auth) => { | |||||
| const abilities= getUserData()?getUserData()["abilities"]:null; | |||||
| if(abilities == null || abilities.length==0) return false; | |||||
| for(let i= 0; i<abilities.length; i++){ | |||||
| if(auth == abilities[i]) return true; | |||||
| } | |||||
| return false; | |||||
| }; | |||||
| /** | /** | ||||
| * This function is used for demo purpose route navigation | * This function is used for demo purpose route navigation | ||||
| * In real app you won't need this function because your app will navigate to same route for each users regardless of ability | * In real app you won't need this function because your app will navigate to same route for each users regardless of ability | ||||
| @@ -1,5 +1,5 @@ | |||||
| // material-ui | // material-ui | ||||
| import * as React from 'react'; | |||||
| import {useState, useEffect} from 'react'; | |||||
| import { | import { | ||||
| DataGrid, GridOverlay, | DataGrid, GridOverlay, | ||||
| } from "@mui/x-data-grid"; | } from "@mui/x-data-grid"; | ||||
| @@ -12,18 +12,18 @@ export function FiDataGrid({ rows, columns, sx, autoHeight, | |||||
| hideFooterSelectedRowCount, rowModesModel, editMode, | hideFooterSelectedRowCount, rowModesModel, editMode, | ||||
| pageSizeOptions, filterItems, customPageSize, ...props }) { | pageSizeOptions, filterItems, customPageSize, ...props }) { | ||||
| const intl = useIntl(); | const intl = useIntl(); | ||||
| const [_rows, set_rows] = React.useState([]); | |||||
| const [_columns, set_columns] = React.useState([]); | |||||
| const [_rowModesModel, set_rowModesModel] = React.useState({}); | |||||
| const [_editMode, set_editMode] = React.useState("row"); | |||||
| const [_pageSizeOptions, set_pageSizeOptions] = React.useState([10, 25, 50]); | |||||
| const [_filterItems, set_filterItems] = React.useState([]); | |||||
| const [_rows, set_rows] = useState([]); | |||||
| const [_columns, set_columns] = useState([]); | |||||
| const [_rowModesModel, set_rowModesModel] = useState({}); | |||||
| const [_editMode, set_editMode] = useState("row"); | |||||
| const [_pageSizeOptions, set_pageSizeOptions] = useState([10, 25, 50]); | |||||
| const [_filterItems, set_filterItems] = useState([]); | |||||
| const [page, setPage] = React.useState(0); | |||||
| const [pageSize, setPageSize] = React.useState(10); | |||||
| const [_autoHeight, set_autoHeight] = React.useState(true); | |||||
| const [myHideFooterSelectedRowCount, setMyHideFooterSelectedRowCount] = React.useState(true); | |||||
| const [_sx, set_sx] = React.useState({ | |||||
| const [page, setPage] = useState(0); | |||||
| const [pageSize, setPageSize] = useState(10); | |||||
| const [_autoHeight, set_autoHeight] = useState(true); | |||||
| const [myHideFooterSelectedRowCount, setMyHideFooterSelectedRowCount] = useState(true); | |||||
| const [_sx, set_sx] = useState({ | |||||
| padding: "4 2 4 2", | padding: "4 2 4 2", | ||||
| '& .MuiDataGrid-cell': { | '& .MuiDataGrid-cell': { | ||||
| borderTop: 1, | borderTop: 1, | ||||
| @@ -36,7 +36,7 @@ export function FiDataGrid({ rows, columns, sx, autoHeight, | |||||
| }, | }, | ||||
| }); | }); | ||||
| React.useEffect(() => { | |||||
| useEffect(() => { | |||||
| if (sx) { | if (sx) { | ||||
| set_sx(sx); | set_sx(sx); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| // material-ui | // material-ui | ||||
| import * as React from 'react'; | |||||
| import {useState, useEffect} from 'react'; | |||||
| import { | import { | ||||
| Button, | Button, | ||||
| Typography, useMediaQuery | Typography, useMediaQuery | ||||
| @@ -16,7 +16,7 @@ import { FormattedMessage, useIntl } from "react-intl"; | |||||
| // ==============================|| EVENT TABLE ||============================== // | // ==============================|| EVENT TABLE ||============================== // | ||||
| export default function SearchPublicNoticeTable({ recordList }) { | export default function SearchPublicNoticeTable({ recordList }) { | ||||
| const [rows, setRows] = React.useState([]); | |||||
| const [rows, setRows] = useState([]); | |||||
| const navigate = useNavigate() | const navigate = useNavigate() | ||||
| const theme = useTheme(); | const theme = useTheme(); | ||||
| const isMdOrLg = useMediaQuery(theme.breakpoints.up('md')); | const isMdOrLg = useMediaQuery(theme.breakpoints.up('md')); | ||||
| @@ -26,7 +26,7 @@ export default function SearchPublicNoticeTable({ recordList }) { | |||||
| navigate('/publicNotice/' + params.id); | navigate('/publicNotice/' + params.id); | ||||
| }; | }; | ||||
| React.useEffect(() => { | |||||
| useEffect(() => { | |||||
| setRows(recordList); | setRows(recordList); | ||||
| }, [recordList]); | }, [recordList]); | ||||
| @@ -74,6 +74,12 @@ const AuthLogin = () => { | |||||
| //setPosts("12354") | //setPosts("12354") | ||||
| console.log(response.data); | console.log(response.data); | ||||
| setPosts(response.data); | setPosts(response.data); | ||||
| let abilities = []; | |||||
| for(let i=0; i<response.data.abilities?.length; i++){ | |||||
| abilities[i] = response.data.abilities[i].actionSubjectCombo; | |||||
| } | |||||
| const userData = { | const userData = { | ||||
| id: response.data.id, | id: response.data.id, | ||||
| fullenName: response.data.name, | fullenName: response.data.name, | ||||
| @@ -81,7 +87,7 @@ const AuthLogin = () => { | |||||
| email: response.data.email, | email: response.data.email, | ||||
| type: response.data.type, | type: response.data.type, | ||||
| role: response.data.role, | role: response.data.role, | ||||
| abilities: response.data.abilities, | |||||
| abilities: abilities, | |||||
| //avatar: require('src/assets/images/users/avatar-3.png').default, | //avatar: require('src/assets/images/users/avatar-3.png').default, | ||||
| } | } | ||||
| // const abilities = response.data.abilities | // const abilities = response.data.abilities | ||||
| @@ -4,6 +4,7 @@ import { lazy } from 'react'; | |||||
| import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
| // import MainLayout from 'layout/MainLayout'; | // import MainLayout from 'layout/MainLayout'; | ||||
| const MainLayout = Loadable(lazy(() => import('layout/MainLayout'))); | const MainLayout = Loadable(lazy(() => import('layout/MainLayout'))); | ||||
| import {checkAuth} from "auth/utils"; | |||||
| // render - dashboard | // render - dashboard | ||||
| const DashboardDefault = Loadable(lazy(() => import('pages/Dashboard/GLD'))); | const DashboardDefault = Loadable(lazy(() => import('pages/Dashboard/GLD'))); | ||||
| @@ -54,10 +55,10 @@ const GLDUserRoutes = { | |||||
| path: '/application/search', | path: '/application/search', | ||||
| element: <ApplicationSearch/> | element: <ApplicationSearch/> | ||||
| }, | }, | ||||
| { | |||||
| checkAuth("VIEW_PROOF") || checkAuth("MAINTAIN_PROOF")?{ | |||||
| path: '/proof/search', | path: '/proof/search', | ||||
| element: <ProofSearch/> | element: <ProofSearch/> | ||||
| }, | |||||
| }:{}, | |||||
| { | { | ||||
| path: '/proof/create/:id', | path: '/proof/create/:id', | ||||
| element: <ProofCreate_FromApp/> | element: <ProofCreate_FromApp/> | ||||