Commit 352ae214 by tdgiang

updaten code

parent abd2af98
{ {
"name": "matx-react", "name": "PetroPos",
"version": "2.0.0", "version": "2.0.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
......
//const root = 'http://petrolpay.tasvietnam.vn:9985/api' //const root = 'http://petrolpay.tasvietnam.vn:9985/api'
const root = 'https://apigw.petropos.vn/api' //const root = 'https://apigw.petropos.vn/api'
//const root = 'http://dcvf.tasvietnam.vn:9986/api'
//const root = 'https://apigw-v2.petropos.vn/api'
const root = 'https://apitest.petropos.vn/api'
export default { export default {
//Dang nhap,thong tin ca nhan //Dang nhap,thong tin ca nhan
...@@ -105,8 +108,6 @@ export default { ...@@ -105,8 +108,6 @@ export default {
updateStatusRequest: `${root}/customerCare/changeStatus`, updateStatusRequest: `${root}/customerCare/changeStatus`,
detailCustomerCare: `${root}/customerCare`, detailCustomerCare: `${root}/customerCare`,
//dropdown //dropdown
dropdownFuntions: `${root}/dropdown/function`, dropdownFuntions: `${root}/dropdown/function`,
dropdownPermission: `${root}/function/getFunctionTree`, dropdownPermission: `${root}/function/getFunctionTree`,
......
...@@ -358,6 +358,8 @@ ...@@ -358,6 +358,8 @@
"ERROR_CODE_IS_EXITS":"Mã code đã tồn tại", "ERROR_CODE_IS_EXITS":"Mã code đã tồn tại",
"ERROR_NAME_IS_EXITS":"Tên sản phẩm đã tồn tại", "ERROR_NAME_IS_EXITS":"Tên sản phẩm đã tồn tại",
"ERROR_MERCHAN_STORE_CODE":"Mã cây xăng đã tồn tại", "ERROR_MERCHAN_STORE_CODE":"Mã cây xăng đã tồn tại",
"ERROR_IMAGE_NOT_VALID":"Ảnh không đúng dịnh dạng" "ERROR_IMAGE_NOT_VALID":"Ảnh không đúng dịnh dạng",
"ERROR_OTP_IS_EXPIRED":"OTP đã hết hạn",
"ERROR_QUEUE_CODE_EXIST":"Mã Queue đã tồn tại"
} }
...@@ -24,6 +24,7 @@ const validateImg = (string) => { ...@@ -24,6 +24,7 @@ const validateImg = (string) => {
function UploadButtons(props) { function UploadButtons(props) {
const { image, onFileChange } = props const { image, onFileChange } = props
const upLoadImage = async (event) => { const upLoadImage = async (event) => {
try {
if (validateImg(event.target.files[0])) { if (validateImg(event.target.files[0])) {
const res = await apiUploadFile( const res = await apiUploadFile(
createFormData(event.target.files[0], {}) createFormData(event.target.files[0], {})
...@@ -43,6 +44,11 @@ function UploadButtons(props) { ...@@ -43,6 +44,11 @@ function UploadButtons(props) {
theme: 'colored', theme: 'colored',
}) })
} }
} catch (error) {
toast.warn('Upload ảnh thất bại!', {
theme: 'colored',
})
}
} }
const createFormData = (photo, body) => { const createFormData = (photo, body) => {
......
...@@ -29,13 +29,13 @@ function UploadButtons(props) { ...@@ -29,13 +29,13 @@ function UploadButtons(props) {
const { images, onFileChange, title } = props const { images, onFileChange, title } = props
const upLoadImage = async (event) => { const upLoadImage = async (event) => {
try {
if (validateImg(event.target.files[0])) { if (validateImg(event.target.files[0])) {
const res = await apiUploadFile( const res = await apiUploadFile(
createFormData(event.target.files[0], {}) createFormData(event.target.files[0], {})
) )
console.log('res image', res)
if (res.data.status == 200 && res.data.data) { if (res.data.status == 200 && res.data.data) {
console.log(res.data.data[0].url)
onFileChange(res.data.data[0].url) onFileChange(res.data.data[0].url)
toast.success('Upload ảnh thành công!', { toast.success('Upload ảnh thành công!', {
theme: 'colored', theme: 'colored',
...@@ -50,6 +50,11 @@ function UploadButtons(props) { ...@@ -50,6 +50,11 @@ function UploadButtons(props) {
theme: 'colored', theme: 'colored',
}) })
} }
} catch (error) {
toast.warn('Upload ảnh thất bại!', {
theme: 'colored',
})
}
} }
const createFormData = (photo, body) => { const createFormData = (photo, body) => {
......
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
Icon, Icon,
Tooltip, Tooltip,
RadioGroup, RadioGroup,
MenuItem, MenuItem,Checkbox
} from '@material-ui/core' } from '@material-ui/core'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
...@@ -42,6 +42,7 @@ export default function FormDialog({ onCreate }) { ...@@ -42,6 +42,7 @@ export default function FormDialog({ onCreate }) {
const [listType, setListType] = useState([]) const [listType, setListType] = useState([])
const [listProduct, setListProduct] = useState([]) const [listProduct, setListProduct] = useState([])
const [product,setProduct]=useState() const [product,setProduct]=useState()
const [is_api,setIsApi]=useState(false)
const [type, setType] = useState() const [type, setType] = useState()
...@@ -103,7 +104,7 @@ export default function FormDialog({ onCreate }) { ...@@ -103,7 +104,7 @@ export default function FormDialog({ onCreate }) {
if(state?.product_id && state?.name?.trim() && state?.code?.trim()){ if(state?.product_id && state?.name?.trim() && state?.code?.trim()){
let index=listProduct.findIndex(e=>e.id==state.product_id) let index=listProduct.findIndex(e=>e.id==state.product_id)
if(index!=-1){ if(index!=-1){
onCreate({...state,type,type_name:listProduct[index].type_name, product_name: listProduct[index].product_name}) onCreate({...state,type,type_name:listProduct[index].type_name, product_name: listProduct[index].product_name,is_api})
setOpen(false) setOpen(false)
setState({}) setState({})
setType() setType()
...@@ -129,7 +130,9 @@ export default function FormDialog({ onCreate }) { ...@@ -129,7 +130,9 @@ export default function FormDialog({ onCreate }) {
}) })
} }
const { product_id, name, code } = state const { product_id, name, code,domain,client_id,client_secret ,supplier_main} = state
return ( return (
<> <>
...@@ -227,10 +230,100 @@ export default function FormDialog({ onCreate }) { ...@@ -227,10 +230,100 @@ export default function FormDialog({ onCreate }) {
))} ))}
</SelectValidator> </SelectValidator>
</Grid> </Grid>
{/* <Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Base url *"
onChange={handleChange}
variant="outlined"
type="text"
name="domain"
value={domain || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Mã khách hàng *"
onChange={handleChange}
variant="outlined"
type="text"
name="client_id"
value={client_id || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Mật khẩu*"
onChange={handleChange}
variant="outlined"
type="text"
name="client_secret"
value={client_secret || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Nhà cung cấp bo mạch *"
onChange={handleChange}
variant="outlined"
type="text"
name="supplier_main"
value={supplier_main || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid lg={12} md={12} sm={12} xs={12} item>
<FormControlLabel
className="min-w-288"
control={
<Checkbox
size="small"
color="primary"
onChange={(event) => {
setIsApi(
event.target.checked
)
}}
value={is_api}
/>
}
label="Sử dụng api truyền nhận"
/>
</Grid> */}
</Grid> </Grid>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button color="secondary" onClick={handleClose}> <Button color="secondary" onClick={()=>{
handleClose()
setType()
setProduct()
setState({})
}}>
Thoát Thoát
</Button> </Button>
<Button onClick={handleSubmit} color="primary"> <Button onClick={handleSubmit} color="primary">
......
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
Icon, Icon,
Tooltip, Tooltip,
RadioGroup, RadioGroup,
MenuItem, MenuItem,Checkbox
} from '@material-ui/core' } from '@material-ui/core'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
...@@ -45,8 +45,8 @@ export default function FormDialog( props) { ...@@ -45,8 +45,8 @@ export default function FormDialog( props) {
const [listProduct, setListProduct] = useState([]) const [listProduct, setListProduct] = useState([])
const [product,setProduct]=useState() const [product,setProduct]=useState()
const [type, setType] = useState() const [type, setType] = useState()
const [is_api,setIsApi]=useState(false)
console.log("data",data)
useEffect(()=>{ useEffect(()=>{
if(data){ if(data){
...@@ -60,7 +60,7 @@ export default function FormDialog( props) { ...@@ -60,7 +60,7 @@ export default function FormDialog( props) {
setProduct(data.product_id) setProduct(data.product_id)
} }
},[data]) },[data,open])
useEffect(()=>{ useEffect(()=>{
...@@ -112,6 +112,7 @@ export default function FormDialog( props) { ...@@ -112,6 +112,7 @@ export default function FormDialog( props) {
const handleSubmit = async (value) => { const handleSubmit = async (value) => {
if(state?.product_id && state?.name?.trim() && state?.code?.trim()){
let index=listProduct.findIndex(e=>e.id==state.product_id) let index=listProduct.findIndex(e=>e.id==state.product_id)
if(index!=-1){ if(index!=-1){
console.log(listProduct[index]) console.log(listProduct[index])
...@@ -119,9 +120,13 @@ export default function FormDialog( props) { ...@@ -119,9 +120,13 @@ export default function FormDialog( props) {
console.log('state', state) console.log('state', state)
onAgree({...state,type,type_name:listProduct[index].type_name, product_name: listProduct[index].product_name})} onAgree({...state,type,type_name:listProduct[index].type_name, product_name: listProduct[index].product_name,code:state.code,is_api})}
}else{ toast.warning('Bạn chưa nhập đầy đủ thông tin', {
theme: 'colored',
})
} }
}
...@@ -133,7 +138,7 @@ export default function FormDialog( props) { ...@@ -133,7 +138,7 @@ export default function FormDialog( props) {
}) })
} }
const { product_id, name, code } = state const { product_id, name, code ,domain,client_id,client_secret ,supplier_main} = state
console.log("listType",listType) console.log("listType",listType)
...@@ -159,7 +164,6 @@ export default function FormDialog( props) { ...@@ -159,7 +164,6 @@ export default function FormDialog( props) {
label="Mã vòi xăng *" label="Mã vòi xăng *"
onChange={handleChange} onChange={handleChange}
variant="outlined" variant="outlined"
disabled={true}
type="text" type="text"
name="code" name="code"
value={code || ''} value={code || ''}
...@@ -230,6 +234,88 @@ export default function FormDialog( props) { ...@@ -230,6 +234,88 @@ export default function FormDialog( props) {
))} ))}
</SelectValidator> </SelectValidator>
</Grid>} </Grid>}
{/*
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Base url *"
onChange={handleChange}
variant="outlined"
type="text"
name="domain"
value={domain || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Mã khách hàng *"
onChange={handleChange}
variant="outlined"
type="text"
name="client_id"
value={client_id || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Mật khẩu*"
onChange={handleChange}
variant="outlined"
type="text"
name="client_secret"
value={client_secret || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Nhà cung cấp bo mạch *"
onChange={handleChange}
variant="outlined"
type="text"
name="supplier_main"
value={supplier_main || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid lg={12} md={12} sm={12} xs={12} item>
<FormControlLabel
className="min-w-288"
control={
<Checkbox
size="small"
color="primary"
onChange={(event) => {
setIsApi(
event.target.checked
)
}}
value={is_api}
/>
}
label="Sử dụng api truyền nhận"
/>
</Grid> */}
</Grid> </Grid>
......
...@@ -14,6 +14,10 @@ export function objectMap(object, mapFn) { ...@@ -14,6 +14,10 @@ export function objectMap(object, mapFn) {
}, {}) }, {})
} }
export function isNumeric(value) {
return /^-?\d+$/.test(value)
}
export const toPriceVndInput = (str) => { export const toPriceVndInput = (str) => {
if (str) { if (str) {
let stringPrice = str.toString().split('.') let stringPrice = str.toString().split('.')
......
...@@ -182,13 +182,13 @@ export const navigationsAdmin = [ ...@@ -182,13 +182,13 @@ export const navigationsAdmin = [
hide: false, hide: false,
}, },
{ // {
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: 'DASHBOARD',
hide: false, // hide: false,
}, // },
{ {
name: 'Yêu cầu tư vấn', name: 'Yêu cầu tư vấn',
path: '/list-request', path: '/list-request',
......
...@@ -50,9 +50,16 @@ const SimpleForm = (props) => { ...@@ -50,9 +50,16 @@ const SimpleForm = (props) => {
const getListAction = async () => { const getListAction = async () => {
if (role) { if (role) {
const res = await actionByGroup(role, {}) const res = await actionByGroup(role, {})
console.log('res.data.data', res.data.data)
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setListAction(res.data.data.userGroupPermissions) if (res.data.data.userGroupPermissions) {
let newList = res.data.data.userGroupPermissions
newList.sort((a, b) =>
a.function_name.localeCompare(b.function_name)
)
setListAction(newList)
}
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
setTimeout(() => { setTimeout(() => {
history.push('/') history.push('/')
......
...@@ -91,7 +91,12 @@ const SimpleForm = (props) => { ...@@ -91,7 +91,12 @@ const SimpleForm = (props) => {
const res = await actionByGroup(role, {}) const res = await actionByGroup(role, {})
console.log('res.data.data', res.data.data) console.log('res.data.data', res.data.data)
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setListAction(res.data.data.userGroupPermissions) let newList = res.data.data.userGroupPermissions
newList.sort((a, b) =>
a.function_name.localeCompare(b.function_name)
)
setListAction(newList)
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
setTimeout(() => { setTimeout(() => {
history.push('/') history.push('/')
......
...@@ -132,18 +132,19 @@ const SimpleForm = (props) => { ...@@ -132,18 +132,19 @@ const SimpleForm = (props) => {
</Grid> </Grid>
</Grid> </Grid>
<Grid container justify={'flex-end'}> <Grid container justify={'flex-end'}>
<Link to="function">
<Button <Button
style={{ style={{
marginRight: 20, marginRight: 20,
}} }}
color="inherit" color="inherit"
variant="contained" variant="contained"
onClick={() => {}} onClick={() => {
history.goBack()
}}
> >
<span className="capitalize">Quay li</span> <span className="capitalize">Quay li</span>
</Button> </Button>
</Link>
<Button <Button
color="primary" color="primary"
variant="contained" variant="contained"
......
...@@ -156,18 +156,19 @@ const SimpleForm = (props) => { ...@@ -156,18 +156,19 @@ const SimpleForm = (props) => {
</Grid> </Grid>
</Grid> </Grid>
<Grid container justify={'flex-end'}> <Grid container justify={'flex-end'}>
<Link to="function">
<Button <Button
style={{ style={{
marginRight: 20, marginRight: 20,
}} }}
color="inherit" color="inherit"
variant="contained" variant="contained"
onClick={() => {}} onClick={() => {
history.goBack()
}}
> >
<span className="capitalize">Quay li</span> <span className="capitalize">Quay li</span>
</Button> </Button>
</Link>
<Button <Button
color="primary" color="primary"
variant="contained" variant="contained"
......
...@@ -77,7 +77,7 @@ const SimpleForm = (props) => { ...@@ -77,7 +77,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Cập nhật hành động thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -72,6 +72,7 @@ const ToolNotificate = (props) => { ...@@ -72,6 +72,7 @@ const ToolNotificate = (props) => {
} }
const getData = async (init) => { const getData = async (init) => {
try {
props.showLoading() props.showLoading()
let res let res
...@@ -105,7 +106,7 @@ const ToolNotificate = (props) => { ...@@ -105,7 +106,7 @@ const ToolNotificate = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setReport(res.data.data.data) setReport(res.data.data.data)
const newList = res.data.data.data.details.map((e, i) => { const newList = res.data.data.data.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize } return { ...e, index: i + 1 + pageIndex * pageSize }
}) })
setData(newList) setData(newList)
...@@ -119,6 +120,11 @@ const ToolNotificate = (props) => { ...@@ -119,6 +120,11 @@ const ToolNotificate = (props) => {
theme: 'colored', theme: 'colored',
}) })
} }
} catch (error) {
toast.error('Hệ thống đang bận, vui lòng thử lại sau', {
theme: 'colored',
})
}
} }
useEffect(() => { useEffect(() => {
......
...@@ -31,7 +31,7 @@ import TableRow from '@material-ui/core/TableRow' ...@@ -31,7 +31,7 @@ import TableRow from '@material-ui/core/TableRow'
import Paper from '@material-ui/core/Paper' import Paper from '@material-ui/core/Paper'
import CreateField from 'app/components/dialog/CreateField' import CreateField from 'app/components/dialog/CreateField'
import CreateFountain from 'app/components/dialog/CreateFountain' import CreateFountain from 'app/components/dialog/CreateFountain'
import UpdateFountain from 'app/components/dialog/UpdateFountain' import UpdateFountain from 'app/components/dialog/UpdateFountainForCreat'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
...@@ -69,9 +69,6 @@ const SimpleForm = (props) => { ...@@ -69,9 +69,6 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
console.log('newValue', newValue)
console.log('listField', listField)
props.showLoading() props.showLoading()
const res = await createGasStation({ const res = await createGasStation({
...newValue, ...newValue,
...@@ -152,16 +149,16 @@ const SimpleForm = (props) => { ...@@ -152,16 +149,16 @@ const SimpleForm = (props) => {
arr.map((e, i) => { arr.map((e, i) => {
if (e.gas_olines) { if (e.gas_olines) {
if ( // if (
e.gas_olines.findIndex( // e.gas_olines.findIndex(
(e) => e.name.toUpperCase() == data.name.toUpperCase() // (e) => e.name.toUpperCase() == data.name.toUpperCase()
) != -1 // ) != -1
) { // ) {
toast.warning('Tên vòi xăng đã tồn tại', { // toast.warning('Tên vòi xăng đã tồn tại', {
theme: 'colored', // theme: 'colored',
}) // })
flag = false // flag = false
} // }
if ( if (
e.gas_olines.findIndex( e.gas_olines.findIndex(
(e) => e.code.toUpperCase() == data.code.toUpperCase() (e) => e.code.toUpperCase() == data.code.toUpperCase()
...@@ -196,9 +193,9 @@ const SimpleForm = (props) => { ...@@ -196,9 +193,9 @@ const SimpleForm = (props) => {
].concat(e.gas_olines), ].concat(e.gas_olines),
} }
} else { } else {
// toast.warning('Mã vòi xăng đã tồn tại', { toast.warning('Tên vòi xăng đã tồn tại', {
// theme: 'colored', theme: 'colored',
// }) })
return { return {
...e, ...e,
gas_olines: e.gas_olines, gas_olines: e.gas_olines,
...@@ -257,15 +254,14 @@ const SimpleForm = (props) => { ...@@ -257,15 +254,14 @@ const SimpleForm = (props) => {
setOpenUpdate(false) setOpenUpdate(false)
} }
const onUpdateField = (data) => { const onUpdateField = (data) => {
console.log('hehe', data)
console.log('fountainSelected', fountainSelected)
let arr = [...listField] let arr = [...listField]
let newList = arr.map((e, i) => { let newList = arr.map((e, i) => {
if (i == fountainSelected.index) { if (i == fountainSelected.index) {
console.log('data', data)
console.log('e.gas_olines', e.gas_olines)
if (e.gas_olines.findIndex((e) => e.code == data.code) != -1) { if (e.gas_olines.findIndex((e) => e.code == data.code) != -1) {
if (
e.gas_olines.findIndex((e) => e.name == data.name) == -1
) {
const temp = e.gas_olines.map((item) => { const temp = e.gas_olines.map((item) => {
if (item.code == data.code) return { ...data } if (item.code == data.code) return { ...data }
return { ...item } return { ...item }
...@@ -275,6 +271,15 @@ const SimpleForm = (props) => { ...@@ -275,6 +271,15 @@ const SimpleForm = (props) => {
gas_olines: temp, gas_olines: temp,
} }
} else { } else {
toast.warning('Tên vòi xăng đã tồn tại', {
theme: 'colored',
})
return {
...e,
gas_olines: e.gas_olines,
}
}
} else {
return { return {
...e, ...e,
gas_olines: e.gas_olines, gas_olines: e.gas_olines,
...@@ -299,7 +304,7 @@ const SimpleForm = (props) => { ...@@ -299,7 +304,7 @@ const SimpleForm = (props) => {
return temp return temp
} }
const { store_name, address, merchant_id, store_code } = state const { store_name, address, merchant_id, store_code, queue_name } = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -378,6 +383,21 @@ const SimpleForm = (props) => { ...@@ -378,6 +383,21 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Mã Queue *"
onChange={handleChange}
type="text"
name="queue_name"
value={queue_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="Địa chỉ *" label="Địa chỉ *"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
...@@ -715,7 +735,6 @@ const SimpleForm = (props) => { ...@@ -715,7 +735,6 @@ const SimpleForm = (props) => {
container container
justify={'flex-end'} justify={'flex-end'}
> >
<Link to="gas-station">
<Button <Button
style={{ style={{
marginRight: 20, marginRight: 20,
...@@ -728,7 +747,7 @@ const SimpleForm = (props) => { ...@@ -728,7 +747,7 @@ const SimpleForm = (props) => {
> >
<span className="capitalize">Quay li</span> <span className="capitalize">Quay li</span>
</Button> </Button>
</Link>
<Button <Button
color="primary" color="primary"
variant="contained" variant="contained"
......
...@@ -100,9 +100,6 @@ const SimpleForm = (props) => { ...@@ -100,9 +100,6 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
console.log('newValue', newValue)
console.log('listField', listField)
props.showLoading() props.showLoading()
const res = await createGasStation({ const res = await createGasStation({
id: newValue?.id, id: newValue?.id,
...@@ -111,6 +108,7 @@ const SimpleForm = (props) => { ...@@ -111,6 +108,7 @@ const SimpleForm = (props) => {
address: newValue?.address, address: newValue?.address,
gas_fields: listField, gas_fields: listField,
store_code: newValue?.store_code, store_code: newValue?.store_code,
queue_name: newValue?.queue_name,
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -189,16 +187,16 @@ const SimpleForm = (props) => { ...@@ -189,16 +187,16 @@ const SimpleForm = (props) => {
arr.map((e, i) => { arr.map((e, i) => {
if (e.gas_olines) { if (e.gas_olines) {
if ( // if (
e.gas_olines.findIndex( // e.gas_olines.findIndex(
(e) => e.name.toUpperCase() == data.name.toUpperCase() // (e) => e.name.toUpperCase() == data.name.toUpperCase()
) != -1 // ) != -1
) { // ) {
toast.warning('Tên vòi xăng đã tồn tại', { // toast.warning('Tên vòi xăng đã tồn tại', {
theme: 'colored', // theme: 'colored',
}) // })
flag = false // flag = false
} // }
if ( if (
e.gas_olines.findIndex( e.gas_olines.findIndex(
(e) => e.code.toUpperCase() == data.code.toUpperCase() (e) => e.code.toUpperCase() == data.code.toUpperCase()
...@@ -234,9 +232,9 @@ const SimpleForm = (props) => { ...@@ -234,9 +232,9 @@ const SimpleForm = (props) => {
].concat(e.gas_olines), ].concat(e.gas_olines),
} }
} else { } else {
// toast.warning('Mã vòi xăng đã tồn tại', { toast.warning('Tên vòi xăng đã tồn tại', {
// theme: 'colored', theme: 'colored',
// }) })
return { return {
...e, ...e,
gas_olines: e.gas_olines, gas_olines: e.gas_olines,
...@@ -298,24 +296,30 @@ const SimpleForm = (props) => { ...@@ -298,24 +296,30 @@ const SimpleForm = (props) => {
setOpenUpdate(false) setOpenUpdate(false)
} }
const onUpdateField = (data) => { const onUpdateField = (data) => {
console.log('hehe', data)
console.log('fountainSelected', fountainSelected)
let arr = [...listField] let arr = [...listField]
let newList = arr.map((e, i) => { let newList = arr.map((e, i) => {
console.log('data', data) if (e.gas_olines.findIndex((e) => e.id == data.id) != -1) {
console.log('e.gas_olines', e.gas_olines) // if (e.gas_olines.findIndex((e) => e.name == data.name) == -1) {
if (e.gas_olines.findIndex((e) => e.code == data.code) != -1) { console.log('gas_olines', e.gas_olines)
const temp = e.gas_olines.map((item) => { const temp = e.gas_olines.map((item) => {
console.log('Run item', item) if (item.id == data.id) return { ...data }
console.log('Run data', data)
if (item.code == data.code) return { ...data }
return { ...item } return { ...item }
}) })
return { return {
...e, ...e,
gas_olines: temp, gas_olines: temp,
} }
// } else {
// toast.warning('Tên vòi xăng đã tồn tại', {
// theme: 'colored',
// })
// return {
// ...e,
// gas_olines: e.gas_olines,
// }
// }
} else { } else {
return { return {
...e, ...e,
...@@ -323,7 +327,6 @@ const SimpleForm = (props) => { ...@@ -323,7 +327,6 @@ const SimpleForm = (props) => {
} }
} }
}) })
console.log('newList', newList)
setListField(newList) setListField(newList)
setOpenUpdate(false) setOpenUpdate(false)
...@@ -369,7 +372,7 @@ const SimpleForm = (props) => { ...@@ -369,7 +372,7 @@ const SimpleForm = (props) => {
} }
} }
const { store_name, address, merchant_id, store_code } = state const { store_name, address, merchant_id, store_code, queue_name } = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -447,6 +450,21 @@ const SimpleForm = (props) => { ...@@ -447,6 +450,21 @@ const SimpleForm = (props) => {
]} ]}
/> />
</Grid> </Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã Queue *"
onChange={handleChange}
type="text"
name="queue_name"
value={queue_name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}> <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
...@@ -721,6 +739,7 @@ const SimpleForm = (props) => { ...@@ -721,6 +739,7 @@ const SimpleForm = (props) => {
</TableCell> */} </TableCell> */}
<TableCell> <TableCell>
{row?.id && (
<Tooltip title="Cập nhật"> <Tooltip title="Cập nhật">
<IconButton <IconButton
onClick={() => { onClick={() => {
...@@ -747,6 +766,8 @@ const SimpleForm = (props) => { ...@@ -747,6 +766,8 @@ const SimpleForm = (props) => {
</Icon> </Icon>
</IconButton> </IconButton>
</Tooltip> </Tooltip>
)}
<Tooltip title="Xoá"> <Tooltip title="Xoá">
<IconButton <IconButton
onClick={() => { onClick={() => {
...@@ -791,7 +812,6 @@ const SimpleForm = (props) => { ...@@ -791,7 +812,6 @@ const SimpleForm = (props) => {
container container
justify={'flex-end'} justify={'flex-end'}
> >
<Link to="gas-station">
<Button <Button
style={{ style={{
marginRight: 20, marginRight: 20,
...@@ -804,7 +824,7 @@ const SimpleForm = (props) => { ...@@ -804,7 +824,7 @@ const SimpleForm = (props) => {
> >
<span className="capitalize">Quay li</span> <span className="capitalize">Quay li</span>
</Button> </Button>
</Link>
<Button <Button
color="primary" color="primary"
variant="contained" variant="contained"
......
...@@ -28,6 +28,7 @@ const SimpleForm = (props) => { ...@@ -28,6 +28,7 @@ const SimpleForm = (props) => {
const [isStore, setIsStore] = useState(false) const [isStore, setIsStore] = useState(false)
const [invoice, setInvoice] = useState(false) const [invoice, setInvoice] = useState(false)
const [payment, setPayment] = useState(false) const [payment, setPayment] = useState(false)
const [isAuto, setAuto] = useState(false)
const [listDrop, setListDrop] = useState([]) const [listDrop, setListDrop] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
const location = useLocation() const location = useLocation()
...@@ -84,6 +85,7 @@ const SimpleForm = (props) => { ...@@ -84,6 +85,7 @@ const SimpleForm = (props) => {
is_admin_store: isStore, is_admin_store: isStore,
is_connect_hddt: invoice, is_connect_hddt: invoice,
is_connect_qr: payment, is_connect_qr: payment,
is_hddt_nomal: isAuto,
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -535,6 +537,27 @@ const SimpleForm = (props) => { ...@@ -535,6 +537,27 @@ const SimpleForm = (props) => {
) : null} ) : null}
{invoice ? ( {invoice ? (
<Grid lg={6} md={6} sm={12} xs={12} item>
<FormControlLabel
className="min-w-288"
control={
<Checkbox
size="small"
color="primary"
onChange={(event) => {
setAuto(
event.target.checked
)
}}
value={isAuto}
/>
}
label="Tự động phát hoá đơn"
/>
</Grid>
) : null}
{invoice && isAuto ? (
<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"
...@@ -544,9 +567,10 @@ const SimpleForm = (props) => { ...@@ -544,9 +567,10 @@ const SimpleForm = (props) => {
type="text" type="text"
name="publish_invoce_time" name="publish_invoce_time"
value={publish_invoce_time || ''} value={publish_invoce_time || ''}
validators={['required']} validators={['required', 'isNumber']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
'Trường này bắt buộc phải nhập số',
]} ]}
/> />
</Grid> </Grid>
......
...@@ -29,6 +29,7 @@ const SimpleForm = (props) => { ...@@ -29,6 +29,7 @@ const SimpleForm = (props) => {
const [isStore, setIsStore] = useState(false) const [isStore, setIsStore] = useState(false)
const [invoice, setInvoice] = useState(false) const [invoice, setInvoice] = useState(false)
const [payment, setPayment] = useState(false) const [payment, setPayment] = useState(false)
const [isAuto, setAuto] = useState(false)
const [listDrop, setListDrop] = useState([]) const [listDrop, setListDrop] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
...@@ -113,6 +114,7 @@ const SimpleForm = (props) => { ...@@ -113,6 +114,7 @@ const SimpleForm = (props) => {
is_admin_store: isStore, is_admin_store: isStore,
is_connect_hddt: invoice, is_connect_hddt: invoice,
is_connect_qr: payment, is_connect_qr: payment,
is_hddt_nomal: isAuto,
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -547,6 +549,27 @@ const SimpleForm = (props) => { ...@@ -547,6 +549,27 @@ const SimpleForm = (props) => {
) : null} ) : null}
{invoice ? ( {invoice ? (
<Grid lg={6} md={6} sm={12} xs={12} item>
<FormControlLabel
className="min-w-288"
control={
<Checkbox
size="small"
color="primary"
onChange={(event) => {
setAuto(
event.target.checked
)
}}
value={isAuto}
/>
}
label="Tự động phát hoá đơn"
/>
</Grid>
) : null}
{invoice && isAuto ? (
<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"
...@@ -556,9 +579,10 @@ const SimpleForm = (props) => { ...@@ -556,9 +579,10 @@ const SimpleForm = (props) => {
type="text" type="text"
name="publish_invoce_time" name="publish_invoce_time"
value={publish_invoce_time || ''} value={publish_invoce_time || ''}
validators={['required']} validators={['required', 'isNumber']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
'Trường này bắt buộc phải nhập số',
]} ]}
/> />
</Grid> </Grid>
...@@ -636,7 +660,6 @@ const SimpleForm = (props) => { ...@@ -636,7 +660,6 @@ const SimpleForm = (props) => {
) : null} ) : null}
</Grid> </Grid>
<Grid container justify={'flex-end'}> <Grid container justify={'flex-end'}>
<Link to="merchant">
<Button <Button
style={{ style={{
marginRight: 20, marginRight: 20,
...@@ -649,7 +672,7 @@ const SimpleForm = (props) => { ...@@ -649,7 +672,7 @@ const SimpleForm = (props) => {
> >
<span className="capitalize">Quay li</span> <span className="capitalize">Quay li</span>
</Button> </Button>
</Link>
<Button <Button
color="primary" color="primary"
variant="contained" variant="contained"
......
...@@ -23,7 +23,7 @@ import { Breadcrumb, SimpleCard } from 'app/components' ...@@ -23,7 +23,7 @@ import { Breadcrumb, SimpleCard } from 'app/components'
import { dropdownProductType } from 'app/apis/Functions/dropdown' import { dropdownProductType } from 'app/apis/Functions/dropdown'
import { Link, useHistory, useLocation } from 'react-router-dom' import { Link, useHistory, useLocation } from 'react-router-dom'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { trimObject, toPriceVndInput } from 'app/config/Function' import { trimObject, toPriceVndInput, isNumeric } from 'app/config/Function'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { createProduct } from 'app/apis/Functions/product' import { createProduct } from 'app/apis/Functions/product'
...@@ -58,6 +58,8 @@ const SimpleForm = (props) => { ...@@ -58,6 +58,8 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
if (isNumeric(newValue.price_default)) {
props.showLoading() props.showLoading()
const res = await createProduct({ const res = await createProduct({
...newValue, ...newValue,
...@@ -75,6 +77,11 @@ const SimpleForm = (props) => { ...@@ -75,6 +77,11 @@ const SimpleForm = (props) => {
theme: 'colored', theme: 'colored',
}) })
} }
} else {
toast.error('Giá mặc định không đúng định dạng', {
theme: 'colored',
})
}
} }
const handleChange = (event) => { const handleChange = (event) => {
......
...@@ -11,7 +11,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' ...@@ -11,7 +11,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components' import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom' import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject, toPriceVndInput } from 'app/config/Function' import { trimObject, toPriceVndInput, isNumeric } from 'app/config/Function'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import localStorageService from 'app/services/localStorageService' import localStorageService from 'app/services/localStorageService'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
...@@ -67,6 +67,7 @@ const SimpleForm = (props) => { ...@@ -67,6 +67,7 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
if (isNumeric(newValue.price_default)) {
props.showLoading() props.showLoading()
const res = await updateProduct({ const res = await updateProduct({
...newValue, ...newValue,
...@@ -84,6 +85,11 @@ const SimpleForm = (props) => { ...@@ -84,6 +85,11 @@ const SimpleForm = (props) => {
theme: 'colored', theme: 'colored',
}) })
} }
} else {
toast.warn('Giá mặc định không đúng định dạng', {
theme: 'colored',
})
}
} }
const handleChange = (event) => { const handleChange = (event) => {
......
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