Commit a18e4537 by tdgiang

update build

parent 03e4f965
...@@ -37,24 +37,35 @@ const SimpleForm = (props) => { ...@@ -37,24 +37,35 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading()
const res = await createPackage({ if (
...newValue, isNumeric(newValue.price) ||
status: 1, newValue.price == '' ||
outstand: 1, !newValue.price
func_id_add: listChecked, ) {
price: newValue.price != '' ? null : newValue.price, props.showLoading()
}) const res = await createPackage({
props.hideLoading() ...newValue,
if (res.data.code == 200) { status: 1,
history.push('/package') outstand: 1,
func_id_add: listChecked,
price: newValue.price != '' ? newValue.price : null,
})
props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Thêm mới gói thành công!', { history.push('/package')
if (res.data.code == 200) {
toast.success('Thêm mới gói 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('Đơn giá không đúng định dạng', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -136,8 +147,6 @@ const SimpleForm = (props) => { ...@@ -136,8 +147,6 @@ const SimpleForm = (props) => {
type="text" type="text"
name="price" name="price"
value={toPriceVndInput(price) || ''} value={toPriceVndInput(price) || ''}
validators={['isNumber']}
errorMessages={['Trường này phải nhập số ']}
/> />
</Grid> </Grid>
<Grid row container item xs={12} sm={12}> <Grid row container item xs={12} sm={12}>
......
...@@ -61,22 +61,33 @@ const SimpleForm = (props) => { ...@@ -61,22 +61,33 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading()
const res = await updatePackage({ if (
...newValue, isNumeric(newValue.price) ||
func_id_add: listChecked, newValue.price == '' ||
price: newValue.price != '' ? null : newValue.price, !newValue.price
}) ) {
props.hideLoading() props.showLoading()
if (res.data.code == 200) { const res = await updatePackage({
history.push('/package') ...newValue,
func_id_add: listChecked,
price: newValue.price != '' ? newValue.price : null,
})
props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Cập nhật gói thành công!', { history.push('/package')
if (res.data.code == 200) {
toast.success('Cập nhật gói 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('Đơn giá không đúng định dạng', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -157,8 +168,6 @@ const SimpleForm = (props) => { ...@@ -157,8 +168,6 @@ const SimpleForm = (props) => {
type="text" type="text"
name="price" name="price"
value={toPriceVndInput(price) || ''} value={toPriceVndInput(price) || ''}
validators={['isNumber']}
errorMessages={['Trường này phải nhập số ']}
/> />
</Grid> </Grid>
<Grid row container item xs={12} sm={12}> <Grid row container item xs={12} sm={12}>
......
...@@ -57,21 +57,32 @@ const SimpleForm = (props) => { ...@@ -57,21 +57,32 @@ const SimpleForm = (props) => {
const history = useHistory() const history = useHistory()
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() if (
const res = await createPriceProduct({ isNumeric(newValue.price) ||
...newValue, newValue.price == '' ||
status: 1, !newValue.price
}) ) {
props.hideLoading() props.showLoading()
if (res.data.code == 200) { const res = await createPriceProduct({
history.push('/price-product') ...newValue,
status: 1,
price: newValue.price != '' ? newValue.price : null,
})
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('/price-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.warn('Đơn giá không đúng định dạng', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -158,15 +169,11 @@ const SimpleForm = (props) => { ...@@ -158,15 +169,11 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Đơn giá *" label="Đơn giá"
onChange={handleChange} onChange={handleChange}
name="price" name="price"
type="text" type="text"
value={toPriceVndInput(price) || ''} value={toPriceVndInput(price) || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/> />
</Grid> </Grid>
<Grid xs={6} sm={6} item> <Grid xs={6} sm={6} item>
......
...@@ -66,13 +66,13 @@ const ToolNotificate = (props) => { ...@@ -66,13 +66,13 @@ const ToolNotificate = (props) => {
if (isInit) { if (isInit) {
setPageIndex(0) setPageIndex(0)
res = await getListPriceProduct({ res = await getListPriceProduct({
func_name: searchDebount, cons_name: searchDebount,
page_no: 0, page_no: 0,
page_size: pageSize, page_size: pageSize,
}) })
} else { } else {
res = await getListPriceProduct({ res = await getListPriceProduct({
func_name: searchDebount, cons_name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
......
...@@ -14,7 +14,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' ...@@ -14,7 +14,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'
...@@ -77,19 +77,30 @@ const SimpleForm = (props) => { ...@@ -77,19 +77,30 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() props.showLoading()
const res = await updatePriceProduct({ if (
...newValue, isNumeric(newValue.price) ||
}) newValue.price == '' ||
props.hideLoading() !newValue.price
if (res.data.code == 200) { ) {
history.push('/price-product') const res = await updatePriceProduct({
...newValue,
price: newValue.price != '' ? newValue.price : null,
})
props.hideLoading()
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('/price-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('Đơn giá không đúng định dạng', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -159,7 +170,7 @@ const SimpleForm = (props) => { ...@@ -159,7 +170,7 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Đơn vị tính *" label="Đơn vị tính"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="unit" name="unit"
...@@ -175,15 +186,11 @@ const SimpleForm = (props) => { ...@@ -175,15 +186,11 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Đơn giá *" label="Đơn giá"
onChange={handleChange} onChange={handleChange}
name="price" name="price"
type="text" type="text"
value={toPriceVndInput(price) || ''} value={toPriceVndInput(price) || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/> />
</Grid> </Grid>
{type_caculator && ( {type_caculator && (
......
...@@ -75,16 +75,6 @@ function CustomerView(props) { ...@@ -75,16 +75,6 @@ function CustomerView(props) {
}} }}
/> />
</Grid> </Grid>
{checkRole(user, '/package-function/create') ? (
<Link to="/package-function/create">
<Button
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>Thêm mi</span>
</Button>
</Link>
) : null}
</Grid> </Grid>
<Table <Table
......
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