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,15 +116,16 @@ function TableList(props) { ...@@ -116,15 +116,16 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/employee/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 125,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -169,27 +170,34 @@ function TableList(props) { ...@@ -169,27 +170,34 @@ function TableList(props) {
) )
})} })}
<TableCell className={classes.border}> {checkRole(
<Select user,
variant={'outlined'} '/employee/changeStatus'
labelId="demo-simple-select-placeholder-label-label" ) && (
id="demo-simple-select-placeholder-label" <TableCell className={classes.border}>
onChange={(e) => <Select
handeChangeActive( variant={'outlined'}
row.id, labelId="demo-simple-select-placeholder-label-label"
e.target.value id="demo-simple-select-placeholder-label"
) onChange={(e) =>
} handeChangeActive(
displayEmpty row.id,
defaultValue={row.status} e.target.value
className={classes.formControl} )
> }
<MenuItem value={1}> displayEmpty
Hot động defaultValue={row.status}
</MenuItem> className={classes.formControl}
<MenuItem value={2}>Khóa</MenuItem> >
</Select> <MenuItem value={1}>
</TableCell> Hot động
</MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/employee/delete') ? ( {checkRole(user, '/employee/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -123,15 +123,16 @@ function TableList(props) { ...@@ -123,15 +123,16 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/function/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 125,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -176,27 +177,34 @@ function TableList(props) { ...@@ -176,27 +177,34 @@ function TableList(props) {
) )
})} })}
<TableCell className={classes.border}> {checkRole(
<Select user,
variant={'outlined'} '/function/changeStatus'
labelId="demo-simple-select-placeholder-label-label" ) && (
id="demo-simple-select-placeholder-label" <TableCell className={classes.border}>
onChange={(e) => <Select
handeChangeActive( variant={'outlined'}
row.id, labelId="demo-simple-select-placeholder-label-label"
e.target.value id="demo-simple-select-placeholder-label"
) onChange={(e) =>
} handeChangeActive(
displayEmpty row.id,
defaultValue={row.status} e.target.value
className={classes.formControl} )
> }
<MenuItem value={1}> displayEmpty
Hot động defaultValue={row.status}
</MenuItem> className={classes.formControl}
<MenuItem value={2}>Khóa</MenuItem> >
</Select> <MenuItem value={1}>
</TableCell> Hot động
</MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/function/delete') ? ( {checkRole(user, '/function/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -117,15 +117,16 @@ function TableList(props) { ...@@ -117,15 +117,16 @@ function TableList(props) {
</TableCell> </TableCell>
))} ))}
<TableCell {checkRole(user, '/group-role/changeStatus') && (
style={{ <TableCell
backgroundColor: colors.headerTable, style={{
width: 125, backgroundColor: colors.headerTable,
}} width: 125,
> }}
Trạng thái >
</TableCell> Trạng thái
</TableCell>
)}
<TableCell <TableCell
style={{ style={{
textAlign: 'center', textAlign: 'center',
...@@ -168,28 +169,34 @@ function TableList(props) { ...@@ -168,28 +169,34 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{checkRole(
<TableCell className={classes.border}> user,
<Select '/group-role/changeStatus'
variant={'outlined'} ) && (
labelId="demo-simple-select-placeholder-label-label" <TableCell className={classes.border}>
id="demo-simple-select-placeholder-label" <Select
onChange={(e) => variant={'outlined'}
handeChangeActive( labelId="demo-simple-select-placeholder-label-label"
row.id, id="demo-simple-select-placeholder-label"
e.target.value onChange={(e) =>
) handeChangeActive(
} row.id,
displayEmpty e.target.value
defaultValue={row.status} )
className={classes.formControl} }
> displayEmpty
<MenuItem value={1}> defaultValue={row.status}
Hot động className={classes.formControl}
</MenuItem> >
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={1}>
</Select> Hot động
</TableCell> </MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell> <TableCell>
{checkRole( {checkRole(
user, user,
......
...@@ -130,15 +130,16 @@ function TableList(props) { ...@@ -130,15 +130,16 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/role/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 125,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -183,27 +184,31 @@ function TableList(props) { ...@@ -183,27 +184,31 @@ function TableList(props) {
) )
})} })}
<TableCell className={classes.border}> {checkRole(user, '/role/changeStatus') && (
<Select <TableCell className={classes.border}>
variant={'outlined'} <Select
labelId="demo-simple-select-placeholder-label-label" variant={'outlined'}
id="demo-simple-select-placeholder-label" labelId="demo-simple-select-placeholder-label-label"
onChange={(e) => id="demo-simple-select-placeholder-label"
handeChangeActive( onChange={(e) =>
row.id, handeChangeActive(
e.target.value row.id,
) e.target.value
} )
displayEmpty }
defaultValue={row.status} displayEmpty
className={classes.formControl} defaultValue={row.status}
> className={classes.formControl}
<MenuItem value={1}> >
Hot động <MenuItem value={1}>
</MenuItem> Hot động
<MenuItem value={2}>Khóa</MenuItem> </MenuItem>
</Select> <MenuItem value={2}>
</TableCell> Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/role/delete') ? ( {checkRole(user, '/role/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -135,15 +135,16 @@ function TableList(props) { ...@@ -135,15 +135,16 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/gas-station/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 125,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -188,27 +189,34 @@ function TableList(props) { ...@@ -188,27 +189,34 @@ function TableList(props) {
) )
})} })}
<TableCell className={classes.border}> {checkRole(
<Select user,
variant={'outlined'} '/gas-station/changeStatus'
labelId="demo-simple-select-placeholder-label-label" ) && (
id="demo-simple-select-placeholder-label" <TableCell className={classes.border}>
onChange={(e) => <Select
handeChangeActive( variant={'outlined'}
row.id, labelId="demo-simple-select-placeholder-label-label"
e.target.value id="demo-simple-select-placeholder-label"
) onChange={(e) =>
} handeChangeActive(
displayEmpty row.id,
defaultValue={row.status} e.target.value
className={classes.formControl} )
> }
<MenuItem value={1}> displayEmpty
Hot động defaultValue={row.status}
</MenuItem> className={classes.formControl}
<MenuItem value={2}>Khóa</MenuItem> >
</Select> <MenuItem value={1}>
</TableCell> Hot động
</MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell> <TableCell>
{checkRole( {checkRole(
user, user,
......
...@@ -135,15 +135,16 @@ function TableList(props) { ...@@ -135,15 +135,16 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/merchant/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 125,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -188,27 +189,35 @@ function TableList(props) { ...@@ -188,27 +189,35 @@ function TableList(props) {
) )
})} })}
<TableCell className={classes.border}> {checkRole(
<Select user,
variant={'outlined'} '/merchant/changeStatus'
labelId="demo-simple-select-placeholder-label-label" ) && (
id="demo-simple-select-placeholder-label" <TableCell className={classes.border}>
onChange={(e) => <Select
handeChangeActive( variant={'outlined'}
row.id, labelId="demo-simple-select-placeholder-label-label"
e.target.value id="demo-simple-select-placeholder-label"
) onChange={(e) =>
} handeChangeActive(
displayEmpty row.id,
defaultValue={row.status} e.target.value
className={classes.formControl} )
> }
<MenuItem value={1}> displayEmpty
Hot động defaultValue={row.status}
</MenuItem> className={classes.formControl}
<MenuItem value={2}>Khóa</MenuItem> >
</Select> <MenuItem value={1}>
</TableCell> Hot động
</MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/merchant/delete') ? ( {checkRole(user, '/merchant/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -115,15 +115,16 @@ function TableList(props) { ...@@ -115,15 +115,16 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/product/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 125,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -167,28 +168,34 @@ function TableList(props) { ...@@ -167,28 +168,34 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{checkRole(
<TableCell className={classes.border}> user,
<Select '/product/changeStatus'
variant={'outlined'} ) && (
labelId="demo-simple-select-placeholder-label-label" <TableCell className={classes.border}>
id="demo-simple-select-placeholder-label" <Select
onChange={(e) => variant={'outlined'}
handeChangeActive( labelId="demo-simple-select-placeholder-label-label"
row.id, id="demo-simple-select-placeholder-label"
e.target.value onChange={(e) =>
) handeChangeActive(
} row.id,
displayEmpty e.target.value
defaultValue={row.status} )
className={classes.formControl} }
> displayEmpty
<MenuItem value={1}> defaultValue={row.status}
Hot động className={classes.formControl}
</MenuItem> >
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={1}>
</Select> Hot động
</TableCell> </MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell> <TableCell>
{checkRole(user, '/product/delete') ? ( {checkRole(user, '/product/delete') ? (
<Tooltip title="Xoá"> <Tooltip title="Xoá">
......
...@@ -110,15 +110,16 @@ function TableList(props) { ...@@ -110,15 +110,16 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/product-type/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 125,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -162,28 +163,34 @@ function TableList(props) { ...@@ -162,28 +163,34 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{checkRole(
<TableCell className={classes.border}> user,
<Select '/product-type/changeStatus'
variant={'outlined'} ) && (
labelId="demo-simple-select-placeholder-label-label" <TableCell className={classes.border}>
id="demo-simple-select-placeholder-label" <Select
onChange={(e) => variant={'outlined'}
handeChangeActive( labelId="demo-simple-select-placeholder-label-label"
row.id, id="demo-simple-select-placeholder-label"
e.target.value onChange={(e) =>
) handeChangeActive(
} row.id,
displayEmpty e.target.value
defaultValue={row.status} )
className={classes.formControl} }
> displayEmpty
<MenuItem value={1}> defaultValue={row.status}
Hot động className={classes.formControl}
</MenuItem> >
<MenuItem value={2}>Khóa</MenuItem> <MenuItem value={1}>
</Select> Hot động
</TableCell> </MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</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