Commit 4c108e10 by tdgiang

update code

parent f012418b
...@@ -6,7 +6,7 @@ import clsx from 'clsx' ...@@ -6,7 +6,7 @@ import clsx from 'clsx'
import useSettings from 'app/hooks/useSettings' import useSettings from 'app/hooks/useSettings'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import useAuth from 'app/hooks/useAuth' import useAuth from 'app/hooks/useAuth'
import {navigationsAdmin} from 'app/navigations' import {navigationsAdmin,navigations} from 'app/navigations'
const useStyles = makeStyles(({ palette, ...theme }) => ({ const useStyles = makeStyles(({ palette, ...theme }) => ({
scrollable: { scrollable: {
...@@ -32,7 +32,7 @@ const Sidenav = ({ children }) => { ...@@ -32,7 +32,7 @@ const Sidenav = ({ children }) => {
const classes = useStyles() const classes = useStyles()
const { settings, updateSettings } = useSettings() const { settings, updateSettings } = useSettings()
const [navigationUser,setNavigationUser]=useState([]) const [navigationUser,setNavigationUser]=useState([])
let navigation = useSelector(({ navigations }) => navigations) //let navigation = useSelector(({ navigations }) => navigations)
const { user } = useAuth() const { user } = useAuth()
useEffect(()=>{ useEffect(()=>{
getNavigationUser() getNavigationUser()
...@@ -47,7 +47,7 @@ const Sidenav = ({ children }) => { ...@@ -47,7 +47,7 @@ const Sidenav = ({ children }) => {
console.log("user",user.user_permissions) console.log("user",user.user_permissions)
if (user.user_permissions?.length > 0) { if (user.user_permissions?.length > 0) {
const newList = navigation.map((item) => { const newList = navigations.map((item) => {
//level 2 //level 2
if (item.children) { if (item.children) {
let flag = false; let flag = false;
......
import { authRoles } from './auth/authRoles'
export const navigations = [ export const navigations = [
{ {
name: 'Dashboard', name: 'Dashboard',
...@@ -14,36 +12,36 @@ export const navigations = [ ...@@ -14,36 +12,36 @@ export const navigations = [
path: '/merchant', path: '/merchant',
icon: 'apartment', icon: 'apartment',
id: 'MERCHANT', id: 'MERCHANT',
hide: false, hide: true,
}, },
{ {
name: 'Quản lý cây xăng', name: 'Quản lý cây xăng',
path: '/gas-station', path: '/gas-station',
icon: 'local_gas_station', icon: 'local_gas_station',
id: 'GAS_STATION', id: 'GAS-STATION',
hide: false, hide: true,
}, },
{ {
name: 'Quản lý sản phẩm', name: 'Quản lý sản phẩm',
icon: 'wb_iridescent', icon: 'wb_iridescent',
hide: false, hide: true,
children: [ children: [
{ {
name: 'Sản phẩm', name: 'Sản phẩm',
path: '/product', path: '/product',
iconText: 'EM', iconText: 'EM',
//icon: 'group', //icon: 'group',
hide: false, hide: true,
id: 'EMPLOYEE', id: 'PRODUCT',
}, },
{ {
name: 'Loại sản phẩm', name: 'Loại sản phẩm',
iconText: 'FN', iconText: 'FN',
path: '/product-type', path: '/product-type',
hide: false, hide: true,
id: 'FUNCTION', id: 'PRODUCT-TYPE',
}, },
], ],
}, },
...@@ -51,72 +49,72 @@ export const navigations = [ ...@@ -51,72 +49,72 @@ export const navigations = [
name: 'Quản lý giao dịch', name: 'Quản lý giao dịch',
path: '/transations', path: '/transations',
icon: 'receipt_long', icon: 'receipt_long',
id: 'DASHBOARD', id: 'TRANSATIONS',
hide: false, hide: true,
}, },
{ {
name: 'Quản lý thu phí', name: 'Quản lý thu phí',
path: '/list-fee', path: '/list-fee',
icon: 'diamond', icon: 'diamond',
id: 'DASHBOARD', id: 'LIST-FEE',
hide: false, hide: true,
}, },
{ {
name: 'Quản lý hệ thống', name: 'Quản lý hệ thống',
icon: 'wb_iridescent', icon: 'wb_iridescent',
hide: false, hide: true,
children: [ children: [
{ {
name: 'Nhân viên', name: 'Nhân viên',
path: '/employee', path: '/employee',
iconText: 'EM', iconText: 'EM',
//icon: 'group', //icon: 'group',
hide: false, hide: true,
id: 'EMPLOYEE', id: 'EMPLOYEE',
}, },
{ {
name: 'Chức năng', name: 'Chức năng',
iconText: 'FN', iconText: 'FN',
path: '/function', path: '/function',
hide: false, hide: true,
id: 'FUNCTION', id: 'FUNCTION',
}, },
{ {
name: 'Hành động', name: 'Hành động',
iconText: 'RO', iconText: 'RO',
path: '/role', path: '/role',
hide: false, hide: true,
id: 'ROLE', id: 'ROLE',
}, },
{ {
name: 'Nhóm quyền', name: 'Nhóm quyền',
iconText: 'GR', iconText: 'GR',
path: '/group-role', path: '/group-role',
hide: false, hide: true,
id: 'GROUP_ROLE', id: 'GROUP-ROLE',
}, },
{ {
name: 'Log login,logout', name: 'Log login,logout',
iconText: 'NO', iconText: 'NO',
path: '/system/log-auth', path: '/system/log-auth',
hide: false, hide: true,
id: 'LOG_AUTH', id: 'LOG_AUTH',
}, },
{ {
name: 'Log Hành động', name: 'Log Hành động',
iconText: 'SM', iconText: 'SM',
path: '/system/log-action', path: '/system/log-action',
hide: false, hide: true,
id: 'LOG_ACTION', id: 'LOG_ACTION',
}, },
{ {
name: 'Log Api', name: 'Log Api',
iconText: 'SM', iconText: 'SM',
path: '/system/log-api', path: '/system/log-api',
hide: false, hide: true,
id: 'LOG_API', id: 'LOG_API',
}, },
], ],
......
...@@ -116,7 +116,7 @@ function TableList(props) { ...@@ -116,7 +116,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/employee/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -125,6 +125,7 @@ function TableList(props) { ...@@ -125,6 +125,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -169,6 +170,10 @@ function TableList(props) { ...@@ -169,6 +170,10 @@ function TableList(props) {
) )
})} })}
{checkRole(
user,
'/employee/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -187,9 +192,12 @@ function TableList(props) { ...@@ -187,9 +192,12 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/employee/delete') ? ( {checkRole(user, '/employee/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -123,7 +123,7 @@ function TableList(props) { ...@@ -123,7 +123,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/function/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -132,6 +132,7 @@ function TableList(props) { ...@@ -132,6 +132,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -176,6 +177,10 @@ function TableList(props) { ...@@ -176,6 +177,10 @@ function TableList(props) {
) )
})} })}
{checkRole(
user,
'/function/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -194,9 +199,12 @@ function TableList(props) { ...@@ -194,9 +199,12 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/function/delete') ? ( {checkRole(user, '/function/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -117,6 +117,7 @@ function TableList(props) { ...@@ -117,6 +117,7 @@ function TableList(props) {
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/group-role/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -125,7 +126,7 @@ function TableList(props) { ...@@ -125,7 +126,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
textAlign: 'center', textAlign: 'center',
...@@ -168,7 +169,10 @@ function TableList(props) { ...@@ -168,7 +169,10 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{checkRole(
user,
'/group-role/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -187,9 +191,12 @@ function TableList(props) { ...@@ -187,9 +191,12 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole( {checkRole(
user, user,
......
...@@ -130,7 +130,7 @@ function TableList(props) { ...@@ -130,7 +130,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/role/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -139,6 +139,7 @@ function TableList(props) { ...@@ -139,6 +139,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -183,6 +184,7 @@ function TableList(props) { ...@@ -183,6 +184,7 @@ function TableList(props) {
) )
})} })}
{checkRole(user, '/role/changeStatus') && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -201,9 +203,12 @@ function TableList(props) { ...@@ -201,9 +203,12 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/role/delete') ? ( {checkRole(user, '/role/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -135,7 +135,7 @@ function TableList(props) { ...@@ -135,7 +135,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/gas-station/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -144,6 +144,7 @@ function TableList(props) { ...@@ -144,6 +144,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -188,6 +189,10 @@ function TableList(props) { ...@@ -188,6 +189,10 @@ function TableList(props) {
) )
})} })}
{checkRole(
user,
'/gas-station/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -206,9 +211,12 @@ function TableList(props) { ...@@ -206,9 +211,12 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole( {checkRole(
user, user,
......
...@@ -135,7 +135,7 @@ function TableList(props) { ...@@ -135,7 +135,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/merchant/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -144,6 +144,7 @@ function TableList(props) { ...@@ -144,6 +144,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -188,6 +189,10 @@ function TableList(props) { ...@@ -188,6 +189,10 @@ function TableList(props) {
) )
})} })}
{checkRole(
user,
'/merchant/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -206,9 +211,13 @@ function TableList(props) { ...@@ -206,9 +211,13 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/merchant/delete') ? ( {checkRole(user, '/merchant/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -115,7 +115,7 @@ function TableList(props) { ...@@ -115,7 +115,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/product/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -124,6 +124,7 @@ function TableList(props) { ...@@ -124,6 +124,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -167,7 +168,10 @@ function TableList(props) { ...@@ -167,7 +168,10 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{checkRole(
user,
'/product/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -186,9 +190,12 @@ function TableList(props) { ...@@ -186,9 +190,12 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/product/delete') ? ( {checkRole(user, '/product/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -110,7 +110,7 @@ function TableList(props) { ...@@ -110,7 +110,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/product-type/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -119,6 +119,7 @@ function TableList(props) { ...@@ -119,6 +119,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -162,7 +163,10 @@ function TableList(props) { ...@@ -162,7 +163,10 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{checkRole(
user,
'/product-type/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -181,9 +185,12 @@ function TableList(props) { ...@@ -181,9 +185,12 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={2}>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole( {checkRole(
user, user,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment