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,22 +24,28 @@ const validateImg = (string) => { ...@@ -24,22 +24,28 @@ 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) => {
if (validateImg(event.target.files[0])) { try {
const res = await apiUploadFile( if (validateImg(event.target.files[0])) {
createFormData(event.target.files[0], {}) const res = await apiUploadFile(
) createFormData(event.target.files[0], {})
if (res.data.status == 200 && res.data.data) { )
onFileChange(res.data.data[0].url) if (res.data.status == 200 && res.data.data) {
toast.success('Upload ảnh thành công!', { onFileChange(res.data.data[0].url)
theme: 'colored', toast.success('Upload ảnh thành công!', {
}) theme: 'colored',
})
} else {
toast.success('Upload ảnh thất bại!', {
theme: 'colored',
})
}
} else { } else {
toast.success('Upload ảnh thất bại!', { toast.warn('File không đúng định dạng!', {
theme: 'colored', theme: 'colored',
}) })
} }
} else { } catch (error) {
toast.warn('File không đúng định dạng!', { toast.warn('Upload ảnh thất bại!', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -29,24 +29,29 @@ function UploadButtons(props) { ...@@ -29,24 +29,29 @@ function UploadButtons(props) {
const { images, onFileChange, title } = props const { images, onFileChange, title } = props
const upLoadImage = async (event) => { const upLoadImage = async (event) => {
if (validateImg(event.target.files[0])) { try {
const res = await apiUploadFile( if (validateImg(event.target.files[0])) {
createFormData(event.target.files[0], {}) const res = await apiUploadFile(
) createFormData(event.target.files[0], {})
console.log('res image', res) )
if (res.data.status == 200 && res.data.data) {
console.log(res.data.data[0].url) if (res.data.status == 200 && res.data.data) {
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',
}) })
} else {
toast.success('Upload ảnh thất bại!', {
theme: 'colored',
})
}
} else { } else {
toast.success('Upload ảnh thất bại!', { toast.warn('File không đúng định dạng!', {
theme: 'colored', theme: 'colored',
}) })
} }
} else { } catch (error) {
toast.warn('File không đúng định dạng!', { toast.warn('Upload ảnh thất bại!', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -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> >
</Button> <span className="capitalize">Quay li</span>
</Link> </Button>
<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> >
</Button> <span className="capitalize">Quay li</span>
</Link> </Button>
<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,50 +72,56 @@ const ToolNotificate = (props) => { ...@@ -72,50 +72,56 @@ const ToolNotificate = (props) => {
} }
const getData = async (init) => { const getData = async (init) => {
props.showLoading() try {
props.showLoading()
let res
let res
if (init) {
setPageIndex(0) if (init) {
res = await listFee({ setPageIndex(0)
text_search: searchDebount, res = await listFee({
page_no: 0, text_search: searchDebount,
page_size: pageSize, page_no: 0,
from_date: startDate ? convertDate(startDate) : null, page_size: pageSize,
to_date: endDate ? convertDate(endDate) : null, from_date: startDate ? convertDate(startDate) : null,
store_id: module, to_date: endDate ? convertDate(endDate) : null,
merchant_id: merchant, store_id: module,
status: status, merchant_id: merchant,
}) status: status,
} else { })
res = await listFee({ } else {
text_search: searchDebount, res = await listFee({
page_no: pageIndex + 1, text_search: searchDebount,
page_size: pageSize, page_no: pageIndex + 1,
from_date: startDate ? convertDate(startDate) : null, page_size: pageSize,
to_date: endDate ? convertDate(endDate) : null, from_date: startDate ? convertDate(startDate) : null,
store_id: module, to_date: endDate ? convertDate(endDate) : null,
merchant_id: merchant, store_id: module,
status: status, merchant_id: merchant,
}) status: status,
} })
}
props.hideLoading()
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
setReport(res.data.data.data) if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.data.details.map((e, i) => { setReport(res.data.data.data)
return { ...e, index: i + 1 + pageIndex * pageSize } const newList = res.data.data.data.map((e, i) => {
}) return { ...e, index: i + 1 + pageIndex * pageSize }
setData(newList) })
setTotalRecord(res.data.data.total_elements) setData(newList)
} else if (res.data.code == 401) { setTotalRecord(res.data.data.total_elements)
setTimeout(() => { } else if (res.data.code == 401) {
history.push('/') setTimeout(() => {
}, 100) history.push('/')
} else { }, 100)
toast.error(t(res.data.error), { } else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
} catch (error) {
toast.error('Hệ thống đang bận, vui lòng thử lại sau', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -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,22 +254,30 @@ const SimpleForm = (props) => { ...@@ -257,22 +254,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) => {
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) {
const temp = e.gas_olines.map((item) => { if (
if (item.code == data.code) return { ...data } e.gas_olines.findIndex((e) => e.name == data.name) == -1
return { ...item } ) {
}) const temp = e.gas_olines.map((item) => {
return { if (item.code == data.code) return { ...data }
...e, return { ...item }
gas_olines: temp, })
return {
...e,
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 {
...@@ -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,20 +735,19 @@ const SimpleForm = (props) => { ...@@ -715,20 +735,19 @@ const SimpleForm = (props) => {
container container
justify={'flex-end'} justify={'flex-end'}
> >
<Link to="gas-station"> <Button
<Button style={{
style={{ marginRight: 20,
marginRight: 20, }}
}} color="inherit"
color="inherit" variant="contained"
variant="contained" onClick={() => {
onClick={() => { history.goBack()
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"
......
...@@ -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,20 +660,19 @@ const SimpleForm = (props) => { ...@@ -636,20 +660,19 @@ 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, }}
}} color="inherit"
color="inherit" variant="contained"
variant="contained" onClick={() => {
onClick={() => { history.goBack()
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"
......
...@@ -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,20 +58,27 @@ const SimpleForm = (props) => { ...@@ -58,20 +58,27 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading()
const res = await createProduct({ if (isNumeric(newValue.price_default)) {
...newValue, props.showLoading()
}) const res = await createProduct({
props.hideLoading() ...newValue,
if (res.data.code == 200) { })
history.push('/product') props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Tạo sản phẩm thành công!', { history.push('/product')
if (res.data.code == 200) {
toast.success('Tạo sản phẩm thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
} else { } else {
toast.error(t(res.data.error), { toast.error('Giá mặc định không đúng định dạng', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -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,20 +67,26 @@ const SimpleForm = (props) => { ...@@ -67,20 +67,26 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() if (isNumeric(newValue.price_default)) {
const res = await updateProduct({ props.showLoading()
...newValue, const res = await updateProduct({
}) ...newValue,
props.hideLoading() })
if (res.data.code == 200) { props.hideLoading()
history.push('/product')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Cập nhật sản phẩm thành công!', { history.push('/product')
if (res.data.code == 200) {
toast.success('Cập nhật sản phẩm thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
} else { } else {
toast.error(t(res.data.error), { toast.warn('Giá mặc định không đúng định dạng', {
theme: 'colored', theme: 'colored',
}) })
} }
......
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