Commit 1ca9425a by tdgiang

update code

parent 352ae214
...@@ -22,3 +22,4 @@ ...@@ -22,3 +22,4 @@
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
.yarn
...@@ -43,12 +43,12 @@ ...@@ -43,12 +43,12 @@
"node-sass": "^7.0.1", "node-sass": "^7.0.1",
"notistack": "^0.8.8", "notistack": "^0.8.8",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"react-date-range": "^1.4.0",
"qwest": "^4.5.0", "qwest": "^4.5.0",
"react": "^16.8.6", "react": "^16.8.6",
"react-apexcharts": "^1.3.7", "react-apexcharts": "^1.3.7",
"react-awesome-selector": "^2.0.0", "react-awesome-selector": "^2.0.0",
"react-beautiful-dnd": "^11.0.4", "react-beautiful-dnd": "^11.0.4",
"react-date-range": "^1.4.0",
"react-dom": "^16.8.6", "react-dom": "^16.8.6",
"react-dropzone": "^11.2.0", "react-dropzone": "^11.2.0",
"react-google-maps": "^9.4.5", "react-google-maps": "^9.4.5",
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="no">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/logo.png" /> <link rel="shortcut icon" href="%PUBLIC_URL%/logo.png" />
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
--> -->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<meta name="google" content="notranslate">
<link <link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900"
rel="stylesheet" rel="stylesheet"
......
...@@ -18,6 +18,7 @@ import GasStationRoutes from './views/GasStation/GasStationRoutes' ...@@ -18,6 +18,7 @@ import GasStationRoutes from './views/GasStation/GasStationRoutes'
import ListRequestRoutes from './views/ListRequest/routes' import ListRequestRoutes from './views/ListRequest/routes'
import SignUp from './views/SignUp/routes' import SignUp from './views/SignUp/routes'
import InvoiceSupplier from './views/InvoiceSupplier/routes' import InvoiceSupplier from './views/InvoiceSupplier/routes'
import Package from './views/package/routers'
const redirectRoute = [ const redirectRoute = [
{ {
...@@ -34,6 +35,7 @@ const errorRoute = [ ...@@ -34,6 +35,7 @@ const errorRoute = [
] ]
const routes = [ const routes = [
...Package,
...InvoiceSupplier, ...InvoiceSupplier,
...SignUp, ...SignUp,
...ListRequestRoutes, ...ListRequestRoutes,
...@@ -53,7 +55,6 @@ const routes = [ ...@@ -53,7 +55,6 @@ const routes = [
...ManageJobRoutes, ...ManageJobRoutes,
...redirectRoute, ...redirectRoute,
...errorRoute, ...errorRoute,
] ]
export default routes export default routes
...@@ -206,6 +206,43 @@ export const navigationsAdmin = [ ...@@ -206,6 +206,43 @@ export const navigationsAdmin = [
}, },
{ {
name: 'Quản lý gói',
icon: 'widgets',
hide: false,
children: [
{
name: 'Danh sách gói',
path: '/package',
iconText: 'EM',
//icon: 'group',
hide: false,
id: 'EMPLOYEE',
},
{
name: 'Danh sách chức năng',
iconText: 'FN',
path: '/package-function',
hide: false,
id: 'FUNCTION',
},
{
name: 'Cấu hình báo giá',
iconText: 'FN',
path: '/package-setting',
hide: false,
id: 'FUNCTION',
},
],
},
{
name: 'Danh sách đăng ký',
path: '/package-register',
icon: 'how_to_reg',
id: 'SIGN-UP',
hide: false,
},
{
name: 'Quản lý hệ thống', name: 'Quản lý hệ thống',
icon: 'wb_iridescent', icon: 'wb_iridescent',
hide: false, hide: false,
......
...@@ -304,7 +304,16 @@ const SimpleForm = (props) => { ...@@ -304,7 +304,16 @@ const SimpleForm = (props) => {
return temp return temp
} }
const { store_name, address, merchant_id, store_code, queue_name } = state const {
store_name,
address,
merchant_id,
store_code,
queue_name,
account,
user_name,
password,
} = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -394,6 +403,7 @@ const SimpleForm = (props) => { ...@@ -394,6 +403,7 @@ const SimpleForm = (props) => {
]} ]}
/> />
</Grid> </Grid>
<Grid item lg={6} md={6} sm={12} xs={12}> <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
variant="outlined" variant="outlined"
...@@ -409,6 +419,41 @@ const SimpleForm = (props) => { ...@@ -409,6 +419,41 @@ const SimpleForm = (props) => {
]} ]}
/> />
</Grid> </Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tài khoản ATC "
onChange={handleChange}
type="text"
name="account"
value={account || ''}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên đăng nhập ATC "
onChange={handleChange}
type="text"
name="user_name"
value={user_name || ''}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mật khẩu ATC"
onChange={handleChange}
type="text"
name="password"
value={password || ''}
/>
</Grid>
{/* <Grid item lg={6} md={6} sm={12} xs={12}> {/* <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
variant="outlined" variant="outlined"
......
...@@ -372,7 +372,16 @@ const SimpleForm = (props) => { ...@@ -372,7 +372,16 @@ const SimpleForm = (props) => {
} }
} }
const { store_name, address, merchant_id, store_code, queue_name } = state const {
store_name,
address,
merchant_id,
store_code,
queue_name,
account,
user_name,
password,
} = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -481,6 +490,41 @@ const SimpleForm = (props) => { ...@@ -481,6 +490,41 @@ const SimpleForm = (props) => {
]} ]}
/> />
</Grid> </Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tài khoản ATC "
onChange={handleChange}
type="text"
name="account"
value={account || ''}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên đăng nhập ATC "
onChange={handleChange}
type="text"
name="user_name"
value={user_name || ''}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mật khẩu ATC"
onChange={handleChange}
type="text"
name="password"
value={password || ''}
/>
</Grid>
{/* <Grid item lg={6} md={6} sm={12} xs={12}> {/* <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
variant="outlined" variant="outlined"
......
...@@ -62,7 +62,7 @@ const columns = [ ...@@ -62,7 +62,7 @@ const columns = [
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'phone', id: 'representative',
label: 'Người đại diện', label: 'Người đại diện',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
Checkbox, Checkbox,
Typography, Typography,
MenuItem, MenuItem,
Tooltip,
} from '@material-ui/core' } from '@material-ui/core'
import { dropdownListSupplier } from 'app/apis/Functions/dropdown' import { dropdownListSupplier } from 'app/apis/Functions/dropdown'
import { createMerchant } from 'app/apis/Functions/merchant' import { createMerchant } from 'app/apis/Functions/merchant'
...@@ -61,7 +62,11 @@ const SimpleForm = (props) => { ...@@ -61,7 +62,11 @@ const SimpleForm = (props) => {
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => { const newList = res.data.data.map((e) => {
return { ...e, name: e.supplier_name, id: e.supplier_code } return {
...e,
name: e.supplier_name,
id: e.supplier_code,
}
}) })
setListDrop(newList) setListDrop(newList)
...@@ -126,7 +131,6 @@ const SimpleForm = (props) => { ...@@ -126,7 +131,6 @@ const SimpleForm = (props) => {
qr_merchant_code, qr_merchant_code,
qr_api_key, qr_api_key,
qr_secret_key, qr_secret_key,
hddt_sign_code, hddt_sign_code,
hddt_account, hddt_account,
hddt_acpass, hddt_acpass,
...@@ -134,7 +138,6 @@ const SimpleForm = (props) => { ...@@ -134,7 +138,6 @@ const SimpleForm = (props) => {
inv_pattern, inv_pattern,
inv_serial, inv_serial,
publish_invoce_time, publish_invoce_time,
supplier_code, supplier_code,
} = state } = state
...@@ -538,6 +541,7 @@ const SimpleForm = (props) => { ...@@ -538,6 +541,7 @@ const SimpleForm = (props) => {
{invoice ? ( {invoice ? (
<Grid lg={6} md={6} sm={12} xs={12} item> <Grid lg={6} md={6} sm={12} xs={12} item>
<Tooltip title="Cho phép chỉnh sửa thông tin giao dịch trước khi phát hành">
<FormControlLabel <FormControlLabel
className="min-w-288" className="min-w-288"
control={ control={
...@@ -552,12 +556,13 @@ const SimpleForm = (props) => { ...@@ -552,12 +556,13 @@ const SimpleForm = (props) => {
value={isAuto} value={isAuto}
/> />
} }
label="Tự động phát hoá đơn" label="Cho phép chỉnh sửa thông tin giao dịch trước khi phát hành"
/> />
</Tooltip>
</Grid> </Grid>
) : null} ) : null}
{invoice && isAuto ? ( {invoice ? (
<Grid item lg={6} md={6} sm={12} xs={12}> <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
variant="outlined" variant="outlined"
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
Checkbox, Checkbox,
Typography, Typography,
MenuItem, MenuItem,
Tooltip,
} from '@material-ui/core' } from '@material-ui/core'
import { updateMerchant, detailMerchant } from 'app/apis/Functions/merchant' import { updateMerchant, detailMerchant } from 'app/apis/Functions/merchant'
...@@ -90,10 +91,14 @@ const SimpleForm = (props) => { ...@@ -90,10 +91,14 @@ const SimpleForm = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
console.log(res.data.data) console.log(res.data.data)
setState(res.data.data) setState({
...res.data.data,
publish_invoce_time: `${res.data.data?.publish_invoce_time}`,
})
setInvoice(res.data.data?.is_connect_hddt) setInvoice(res.data.data?.is_connect_hddt)
setPayment(res.data.data?.is_connect_qr) setPayment(res.data.data?.is_connect_qr)
setIsStore(res.data.data?.is_admin_store) setIsStore(res.data.data?.is_admin_store)
setAuto(res.data.data?.is_hddt_nomal)
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
setTimeout(() => { setTimeout(() => {
history.push('/') history.push('/')
...@@ -550,6 +555,7 @@ const SimpleForm = (props) => { ...@@ -550,6 +555,7 @@ const SimpleForm = (props) => {
{invoice ? ( {invoice ? (
<Grid lg={6} md={6} sm={12} xs={12} item> <Grid lg={6} md={6} sm={12} xs={12} item>
<Tooltip title="Cho phép chỉnh sửa thông tin giao dịch trước khi phát hành">
<FormControlLabel <FormControlLabel
className="min-w-288" className="min-w-288"
control={ control={
...@@ -561,15 +567,17 @@ const SimpleForm = (props) => { ...@@ -561,15 +567,17 @@ const SimpleForm = (props) => {
event.target.checked event.target.checked
) )
}} }}
checked={isAuto}
value={isAuto} value={isAuto}
/> />
} }
label="Tự động phát hoá đơn" label="Cho phép chỉnh sửa thông tin giao dịch trước khi phát hành"
/> />
</Tooltip>
</Grid> </Grid>
) : null} ) : null}
{invoice && isAuto ? ( {invoice ? (
<Grid item lg={6} md={6} sm={12} xs={12}> <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
variant="outlined" variant="outlined"
......
...@@ -70,12 +70,12 @@ const columns = [ ...@@ -70,12 +70,12 @@ const columns = [
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
}, },
// { {
// id: 'city', id: 'date_created',
// label: 'Tỉnh/ Thành phố', label: 'Ngày tạo yêu cầu',
// align: 'left', align: 'left',
// minWidth: 'auto', minWidth: 120,
// }, },
] ]
function TableList(props) { function TableList(props) {
......
import React, { useState, useEffect } from 'react'
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator'
import { Button, Grid } from '@material-ui/core'
import { createFunction } from 'app/apis/Functions/function'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const { t } = useTranslation()
const history = useHistory()
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createFunction({
...newValue,
status: 1,
is_default: true,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/function')
if (res.data.code == 200) {
toast.success('Tạo chức năng thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const { description, name, code, url } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách chức năng',
path: '/function',
},
{ name: 'Thêm mới chức năng' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên chức năng *"
onChange={handleChange}
type="text"
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã code *"
onChange={handleChange}
type="text"
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Đường dẫn *"
onChange={handleChange}
type="text"
name="url"
value={url || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mô tả"
onChange={handleChange}
type="text"
name="description"
value={description || ''}
// validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {
history.goBack()
}}
>
<span className="capitalize">Quay li</span>
</Button>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Thêm mi</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListFunction,
deleteFunction,
changeStatusFunction,
} from 'app/apis/Functions/function'
import { useHistory } from 'react-router-dom'
import KEY from '../../../assets/Key'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const searchDebount = useDebounce(txtSearch, 1000)
const { t } = useTranslation()
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const history = useHistory()
const [data, setData] = useState([])
const [permissions, setPermissions] = useState([])
// useEffect(() => {
// getListPermission();
// }, []);
// const getListPermission = () => {
// let temp = localStorage.getItem(KEY.LISTPATH);
// let listPath = JSON.parse(temp);
// if (listPath) {
// const newlist = listPath.map((e) => {
// if (e.function_code) return e.function_code;
// return e.action_code;
// });
// setPermissions(newlist);
// }
// };
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusFunction({ id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Thay đổi trạng thái thành công!', {
theme: 'colored',
})
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const getData = async (isInit) => {
props.showLoading()
let res
if (isInit) {
setPageIndex(0)
res = await getListFunction({
name: searchDebount,
page_no: 0,
page_size: pageSize,
})
} else {
res = await getListFunction({
name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
})
}
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(res.data)
const newList = res.data.data.data.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
useEffect(() => {
getData(true)
}, [searchDebount])
useEffect(() => {
getData(false)
}, [pageIndex])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteFunction({ id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Xoá bản ghi thành công!', {
theme: 'colored',
})
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
return (
<ToolUserView
data={data}
removeItem={removeItem}
setTxtSearch={setTxtSearch}
setActiveSeleted={setActiveSeleted}
pageIndex={pageIndex}
changeActive={changeActive}
setChangeActive={setChangeActive}
setPageIndex={setPageIndex}
activeSelected={activeSelected}
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
permissions={permissions}
/>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
ToolNotificate
)
import React, { useState } from 'react'
import {
Paper,
Table,
TableBody,
TableCell,
TableHead,
TableContainer,
TablePagination,
TableRow,
IconButton,
MenuItem,
Select,
Modal,
Fade,
Grid,
Backdrop,
Link,
Button,
Tooltip,
Icon,
} from '@material-ui/core'
import EditIcon from '@material-ui/icons/Edit'
import DeleteIcon from '@material-ui/icons/Delete'
import colors from '../../../assets/Color'
import useStyles from '../../../styles/Table'
import { Breadcrumb, SimpleCard } from 'app/components'
import DialogTransition from 'app/components/dialog/DialogTransition'
import { useHistory } from 'react-router-dom'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
const columns = [
{
id: 'index',
label: 'STT',
align: 'center',
minWidth: 50,
},
{
id: 'name',
label: 'Tên chức năng',
align: 'left',
minWidth: 'auto',
},
{
id: 'code',
label: 'Mã code',
align: 'left',
minWidth: 'auto',
},
{
id: 'url',
label: 'Đường dẫn',
align: 'left',
minWidth: 'auto',
},
{
id: 'description',
label: 'Mô tả',
align: 'left',
minWidth: 'auto',
},
{
id: 'date_created',
label: 'Ngày tạo',
align: 'left',
minWidth: 'auto',
},
]
function TableList(props) {
const {
data,
handeChangeActive,
removeItem,
changeActive,
setChangeActive,
setPageIndex,
setPageSize,
pageIndex,
totalRecords,
permissions,
} = props
const classes = useStyles()
let history = useHistory()
const [selected, setSelected] = useState({
name: '',
id: '',
title: '',
content: '',
})
const [open, setOpen] = React.useState(false)
const { user } = useAuth()
const handleChangePage = (event, newPage) => {
setPageIndex(newPage)
}
const handleChangeRowsPerPage = (event) => {
setPageSize(event.target.value)
}
const handleClose = () => {
setOpen(false)
}
return (
<Paper className={classes.root}>
<TableContainer className={classes.container}>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
{columns.map((column) => (
<TableCell
key={column.id}
align={'center'}
style={{
width: column.minWidth,
backgroundColor: colors.headerTable,
}}
>
{column.label}
</TableCell>
))}
{checkRole(user, '/function/changeStatus') && (
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 125,
}}
>
Trạng thái
</TableCell>
)}
<TableCell
style={{
textAlign: 'center',
backgroundColor: colors.headerTable,
width: 120,
}}
>
Hành động
</TableCell>
</TableRow>
</TableHead>
<TableBody className={classes.columnTable}>
{data.map((row) => {
return (
<TableRow
hover
role="checkbox"
tabIndex={-1}
key={row.id}
>
{columns.map((column) => {
const imageUrl = row[column.id]
return (
<TableCell
key={column.id}
align={column.align}
>
{column.format ? (
<img
src={column.format(
imageUrl
)}
className={
classes.image
}
/>
) : (
imageUrl
)}
</TableCell>
)
})}
{checkRole(
user,
'/function/changeStatus'
) && (
<TableCell className={classes.border}>
<Select
variant={'outlined'}
labelId="demo-simple-select-placeholder-label-label"
id="demo-simple-select-placeholder-label"
onChange={(e) =>
handeChangeActive(
row.id,
e.target.value
)
}
displayEmpty
defaultValue={row.status}
className={classes.formControl}
>
<MenuItem value={1}>
Hot động
</MenuItem>
<MenuItem value={2}>
Khóa
</MenuItem>
</Select>
</TableCell>
)}
<TableCell>
{checkRole(user, '/function/delete') ? (
<Tooltip title="Xoá">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Xóa chức năng',
content: `Bạn có muốn xóa chức năng ${row.name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
) : null}
{checkRole(user, '/function/update') ? (
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {
history.push({
pathname:
'/function/update',
state: row.id,
})
}}
className={classes.button}
aria-label="edit"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
) : null}
</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
</TableContainer>
<DialogTransition
data={selected}
open={open}
handleClose={handleClose}
onAgree={() => {
removeItem(selected.id)
handleClose()
}}
/>
<TablePagination
component="div"
page={pageIndex}
count={totalRecords}
rowsPerPage={10}
rowsPerPageOptions={[]}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</Paper>
)
}
export default TableList
import React, { useState, useEffect } from 'react'
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator'
import { Button, Grid } from '@material-ui/core'
import { detailFunction, updateFunction } from 'app/apis/Functions/function'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux'
import localStorageService from 'app/services/localStorageService'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const history = useHistory()
const location = useLocation()
const { t } = useTranslation()
useEffect(() => {
getData()
}, [])
const getData = async () => {
props.showLoading()
const res = await detailFunction(location.state, {})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
setState(res.data.data)
} else if (res.data.code == 401) {
localStorageService.removeToken()
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await updateFunction({
...newValue,
status: 1,
is_default: true,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/function')
if (res.data.code == 200) {
toast.success('Cập nhật chức năng thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const { description, name, code, url } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách chức năng',
path: '/function',
},
{ name: 'Cập nhật chức năng' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên chức năng *"
onChange={handleChange}
type="text"
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã code *"
onChange={handleChange}
type="text"
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Đường dẫn *"
onChange={handleChange}
type="text"
name="url"
value={url || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mô tả "
onChange={handleChange}
type="text"
name="description"
value={description || ''}
//validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {
history.goBack()
}}
>
<span className="capitalize">Quay li</span>
</Button>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Cp nht</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { Fragment, useState, useEffect } from 'react'
import {
TextField,
Icon,
Button,
StepLabel,
Step,
Stepper,
Grid,
FormControl,
InputLabel,
Select,
MenuItem,
} from '@material-ui/core'
import Table from './Table'
import { Breadcrumb } from 'app/components'
import { Link } from 'react-router-dom'
import { Autocomplete, createFilterOptions } from '@material-ui/lab'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
function CustomerView(props) {
const {
data,
updateItem,
removeItem,
setTxtSearch,
changeActive,
setChangeActive,
handeChangeActive,
setPageIndex,
pageIndex,
totalRecords,
permissions,
} = props
const [age, setAge] = React.useState('')
const { user } = useAuth()
const handleChange = (event) => {
setAge(event.target.value)
}
return (
<Fragment>
<div className="m-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Danh sách chức năng',
path: '/function',
},
]}
/>
</div>
<Grid
style={{
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid item lg={3} md={3} sm={6} xs={6}>
<TextField
variant="outlined"
className="w-full"
label="Nhập từ khoá"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
{checkRole(user, '/function/create') ? (
<Link to="/function/create">
<Button
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>Thêm mi</span>
</Button>
</Link>
) : null}
</Grid>
<Table
data={data}
changeActive={changeActive}
setChangeActive={setChangeActive}
handeChangeActive={handeChangeActive}
updateItem={updateItem}
removeItem={removeItem}
pageIndex={pageIndex}
setPageIndex={setPageIndex}
totalRecords={totalRecords}
permissions={permissions}
/>
</div>
</Fragment>
)
}
export default CustomerView
import React from 'react'
const ProductRoutes = [
{
path: '/package-function/create',
component: React.lazy(() => import('./function/Create')),
},
{
path: '/package-function/update',
component: React.lazy(() => import('./function/Update')),
},
{
path: '/package-function',
component: React.lazy(() => import('./function/Index')),
},
]
export default ProductRoutes
This source diff could not be displayed because it is too large. You can view the blob instead.
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