Commit 2c69692f by tdgiang

update code

parent 5acc8772
...@@ -45,11 +45,18 @@ export default function FormDialog( props) { ...@@ -45,11 +45,18 @@ 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()
console.log("data",data)
useEffect(()=>{ useEffect(()=>{
if(data){ if(data){
setState({...data}) setState({...data})
setType(data.type) if(data.type){
setType(data.type)
}else{
setType(data.product_type_id)
}
setProduct(data.product_id) setProduct(data.product_id)
} }
...@@ -128,7 +135,7 @@ export default function FormDialog( props) { ...@@ -128,7 +135,7 @@ export default function FormDialog( props) {
const { product_id, name, code } = state const { product_id, name, code } = state
console.log("product_id",product_id) console.log("listType",listType)
return ( return (
...@@ -140,7 +147,7 @@ export default function FormDialog( props) { ...@@ -140,7 +147,7 @@ export default function FormDialog( props) {
> >
<DialogTitle id="form-dialog-title"> <DialogTitle id="form-dialog-title">
Thêm vòi xăng Cập nhật vòi xăng
</DialogTitle> </DialogTitle>
<DialogContent> <DialogContent>
......
...@@ -8,7 +8,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' ...@@ -8,7 +8,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { dropdownStore, dropdownMerchant } from 'app/apis/Functions/dropdown' import { dropdownStore, dropdownMerchant } from 'app/apis/Functions/dropdown'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const [applications, setApplications] = useState('') const [applications, setApplications] = useState('')
...@@ -20,7 +20,7 @@ const ToolNotificate = (props) => { ...@@ -20,7 +20,7 @@ const ToolNotificate = (props) => {
const [startDate, setStartDate] = useState(new Date()) const [startDate, setStartDate] = useState(new Date())
const [endDate, setEndDate] = useState(new Date()) const [endDate, setEndDate] = useState(new Date())
const [report, setReport] = useState() const [report, setReport] = useState()
const { t } = useTranslation()
const [listModule, setListModule] = useState([]) const [listModule, setListModule] = useState([])
const [listMerchant, setListMerchant] = useState([]) const [listMerchant, setListMerchant] = useState([])
const [merchant, setMerchant] = useState() const [merchant, setMerchant] = useState()
...@@ -97,7 +97,7 @@ const ToolNotificate = (props) => { ...@@ -97,7 +97,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy dữ liệu thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -32,7 +32,7 @@ import Paper from '@material-ui/core/Paper' ...@@ -32,7 +32,7 @@ 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/UpdateFountain'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const history = useHistory() const history = useHistory()
...@@ -41,7 +41,7 @@ const SimpleForm = (props) => { ...@@ -41,7 +41,7 @@ const SimpleForm = (props) => {
const [listField, setListField] = useState([]) const [listField, setListField] = useState([])
const [fountainSelected, setFountainSelected] = useState() const [fountainSelected, setFountainSelected] = useState()
const [openUpdate, setOpenUpdate] = useState() const [openUpdate, setOpenUpdate] = useState()
const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getData() getData()
}, []) }, [])
...@@ -86,7 +86,7 @@ const SimpleForm = (props) => { ...@@ -86,7 +86,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Tạo cây xăng thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -264,7 +264,7 @@ const SimpleForm = (props) => { ...@@ -264,7 +264,7 @@ const SimpleForm = (props) => {
return temp return temp
} }
const { store_name, address, merchan_id } = state const { store_name, address, merchant_id } = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -292,9 +292,9 @@ const SimpleForm = (props) => { ...@@ -292,9 +292,9 @@ const SimpleForm = (props) => {
variant={'outlined'} variant={'outlined'}
label={'Thuộc pháp nhân *'} label={'Thuộc pháp nhân *'}
className="mb-4 w-full" className="mb-4 w-full"
value={merchan_id || ''} value={merchant_id || ''}
displayEmpty displayEmpty
name="merchan_id" name="merchant_id"
onChange={handleChange} onChange={handleChange}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
......
...@@ -11,36 +11,29 @@ import { connect } from 'react-redux' ...@@ -11,36 +11,29 @@ import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { dropdownMerchant } from 'app/apis/Functions/dropdown'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const searchDebount = useDebounce(txtSearch, 1000) const searchDebount = useDebounce(txtSearch, 1000)
const { t } = useTranslation()
const [activeSelected, setActiveSeleted] = useState(null) const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1) const [changeActive, setChangeActive] = useState(1)
const [pageIndex, setPageIndex] = useState(0) const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10) const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
const [listMerchant, setListMerchant] = useState([])
const [merchant, setMerchant] = useState()
const history = useHistory() const history = useHistory()
const [data, setData] = useState([]) const [data, setData] = useState([])
const [permissions, setPermissions] = useState([]) const [permissions, setPermissions] = useState([])
// useEffect(() => { useEffect(() => {
// getListPermission(); getDropDownMerchant()
// }, []); }, [])
// 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) => { const handeChangeActive = async (id, status_id) => {
props.showLoading() props.showLoading()
...@@ -52,7 +45,7 @@ const ToolNotificate = (props) => { ...@@ -52,7 +45,7 @@ const ToolNotificate = (props) => {
theme: 'colored', theme: 'colored',
}) })
} else { } else {
toast.error('Thay đổi trạng thái thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -61,9 +54,10 @@ const ToolNotificate = (props) => { ...@@ -61,9 +54,10 @@ const ToolNotificate = (props) => {
const getData = async () => { const getData = async () => {
props.showLoading() props.showLoading()
const res = await getListGasStation({ const res = await getListGasStation({
name: searchDebount, text_search: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
merchant_id: merchant,
}) })
props.hideLoading() props.hideLoading()
...@@ -82,13 +76,28 @@ const ToolNotificate = (props) => { ...@@ -82,13 +76,28 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
// enqueueSnackbar('Error!', { variant: 'error' }) toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const getDropDownMerchant = async () => {
try {
const res = await dropdownMerchant()
console.log(res)
const newList = res.data.data.map((e) => {
return { ...e, name: e.merchant_name }
})
setListMerchant(newList)
} catch (err) {
//toast.error(t(err))
} }
} }
useEffect(() => { useEffect(() => {
getData() getData()
}, [searchDebount, pageIndex]) }, [searchDebount, pageIndex, merchant])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
...@@ -105,7 +114,7 @@ const ToolNotificate = (props) => { ...@@ -105,7 +114,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Xoá bản ghi thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -125,6 +134,9 @@ const ToolNotificate = (props) => { ...@@ -125,6 +134,9 @@ const ToolNotificate = (props) => {
handeChangeActive={handeChangeActive} handeChangeActive={handeChangeActive}
totalRecords={totalRecords} totalRecords={totalRecords}
permissions={permissions} permissions={permissions}
listMerchant={listMerchant}
merchant={merchant}
setMerchant={setMerchant}
/> />
) )
} }
......
...@@ -70,7 +70,7 @@ const SimpleForm = (props) => { ...@@ -70,7 +70,7 @@ const SimpleForm = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy thông tin bản ghi thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -120,7 +120,7 @@ const SimpleForm = (props) => { ...@@ -120,7 +120,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Cập nhật cây xăng thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -168,7 +168,13 @@ const SimpleForm = (props) => { ...@@ -168,7 +168,13 @@ const SimpleForm = (props) => {
const deletePillar = (index) => { const deletePillar = (index) => {
let arr = [...listField] let arr = [...listField]
console.log('arr', arr)
if (arr[index].id) {
callApiDeletePillar(arr[index].id)
}
arr.splice(index, 1) arr.splice(index, 1)
setListField(arr) setListField(arr)
toast.success('Xoá trụ thành công!', { toast.success('Xoá trụ thành công!', {
theme: 'colored', theme: 'colored',
...@@ -264,26 +270,27 @@ const SimpleForm = (props) => { ...@@ -264,26 +270,27 @@ const SimpleForm = (props) => {
let arr = [...listField] let arr = [...listField]
let newList = arr.map((e, i) => { let newList = arr.map((e, i) => {
if (i == fountainSelected.index) { console.log('data', data)
console.log('data', data) console.log('e.gas_olines', e.gas_olines)
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) => {
const temp = e.gas_olines.map((item) => { console.log('Run item', item)
if (item.code == data.code) return { ...data } console.log('Run data', data)
return { ...item } if (item.code == data.code) return { ...data }
}) return { ...item }
return { })
...e, return {
gas_olines: temp, ...e,
} gas_olines: temp,
} else {
return {
...e,
gas_olines: e.gas_olines,
}
} }
} else return { ...e } } else {
return {
...e,
gas_olines: e.gas_olines,
}
}
}) })
console.log('newList', newList)
setListField(newList) setListField(newList)
setOpenUpdate(false) setOpenUpdate(false)
...@@ -315,6 +322,20 @@ const SimpleForm = (props) => { ...@@ -315,6 +322,20 @@ const SimpleForm = (props) => {
} }
} }
const callApiDeletePillar = async (id) => {
props.showLoading()
const res = await deleteGasField({ idGuid: id })
props.hideLoading()
if (res.data.code == 200) {
return true
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
return false
}
}
const { store_name, address, merchant_id } = state const { store_name, address, merchant_id } = state
return ( return (
......
...@@ -31,6 +31,9 @@ function CustomerView(props) { ...@@ -31,6 +31,9 @@ function CustomerView(props) {
pageIndex, pageIndex,
totalRecords, totalRecords,
permissions, permissions,
merchant,
setMerchant,
listMerchant,
} = props } = props
const [age, setAge] = React.useState('') const [age, setAge] = React.useState('')
const { user } = useAuth() const { user } = useAuth()
...@@ -62,18 +65,55 @@ function CustomerView(props) { ...@@ -62,18 +65,55 @@ function CustomerView(props) {
container container
spacing={3} spacing={3}
> >
<Grid item lg={3} md={3} sm={6} xs={6}> <Grid
<TextField spacing={3}
variant="outlined" container
className="w-full" item
label="Tên cây xăng" lg={8}
onChange={(e) => { md={8}
const text = e.target.value sm={8}
setTimeout(() => { xs={8}
setTxtSearch(text) >
}, 1000) <Grid item lg={4} md={4} sm={6} xs={6}>
}} <TextField
/> variant="outlined"
className="w-full"
label="Tên cây xăng"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
<Grid item lg={4} md={4} sm={6} xs={6}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Pháp nhân
</InputLabel>
<Select
label="Pháp nhân"
value={merchant}
onChange={(e) =>
setMerchant(e.target.value)
}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listMerchant.map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid> </Grid>
{checkRole(user, '/gas-station/create') ? ( {checkRole(user, '/gas-station/create') ? (
<Link to="/gas-station/create"> <Link to="/gas-station/create">
......
...@@ -11,7 +11,7 @@ import { connect } from 'react-redux' ...@@ -11,7 +11,7 @@ import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const searchDebount = useDebounce(txtSearch, 1000) const searchDebount = useDebounce(txtSearch, 1000)
...@@ -24,7 +24,7 @@ const ToolNotificate = (props) => { ...@@ -24,7 +24,7 @@ const ToolNotificate = (props) => {
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
const history = useHistory() const history = useHistory()
const { t } = useTranslation()
const [data, setData] = useState([]) const [data, setData] = useState([])
const [permissions, setPermissions] = useState([]) const [permissions, setPermissions] = useState([])
...@@ -38,7 +38,7 @@ const ToolNotificate = (props) => { ...@@ -38,7 +38,7 @@ const ToolNotificate = (props) => {
theme: 'colored', theme: 'colored',
}) })
} else { } else {
toast.error('Thay đổi trạng thái thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -63,13 +63,10 @@ const ToolNotificate = (props) => { ...@@ -63,13 +63,10 @@ const ToolNotificate = (props) => {
setData(newList) setData(newList)
setTotalRecord(res.data.data.total_elements) setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else { } else {
// enqueueSnackbar('Error!', { variant: 'error' }) toast.error(t(res.data.error), {
theme: 'colored',
})
} }
} }
...@@ -86,13 +83,8 @@ const ToolNotificate = (props) => { ...@@ -86,13 +83,8 @@ const ToolNotificate = (props) => {
toast.success('Xoá bản ghi thành công!', { toast.success('Xoá bản ghi thành công!', {
theme: 'colored', theme: 'colored',
}) })
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else { } else {
toast.error('Xoá bản ghi thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -7,7 +7,7 @@ import { connect } from 'react-redux' ...@@ -7,7 +7,7 @@ import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const [applications, setApplications] = useState('') const [applications, setApplications] = useState('')
...@@ -18,7 +18,7 @@ const ToolNotificate = (props) => { ...@@ -18,7 +18,7 @@ const ToolNotificate = (props) => {
const searchDebount = useDebounce(txtSearch, 1000) const searchDebount = useDebounce(txtSearch, 1000)
const [startDate, setStartDate] = useState() const [startDate, setStartDate] = useState()
const [endDate, setEndDate] = useState() const [endDate, setEndDate] = useState()
const { t } = useTranslation()
const [data, setData] = useState([]) const [data, setData] = useState([])
const changeDateRange = (start, end) => { const changeDateRange = (start, end) => {
...@@ -49,7 +49,7 @@ const ToolNotificate = (props) => { ...@@ -49,7 +49,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy dữ liệu thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -27,11 +27,12 @@ import { trimObject, toPriceVndInput } from 'app/config/Function' ...@@ -27,11 +27,12 @@ import { trimObject, toPriceVndInput } 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'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([]) const [listDrop, setListDrop] = useState([])
const history = useHistory() const history = useHistory()
const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getData() getData()
}, []) }, [])
...@@ -49,7 +50,7 @@ const SimpleForm = (props) => { ...@@ -49,7 +50,7 @@ const SimpleForm = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy giữ liệu thất bại !', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -70,7 +71,7 @@ const SimpleForm = (props) => { ...@@ -70,7 +71,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Tạo sản phẩm thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -11,7 +11,7 @@ import { connect } from 'react-redux' ...@@ -11,7 +11,7 @@ import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null) const [activeSelected, setActiveSeleted] = useState(null)
...@@ -23,7 +23,7 @@ const ToolNotificate = (props) => { ...@@ -23,7 +23,7 @@ const ToolNotificate = (props) => {
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
const history = useHistory() const history = useHistory()
const { t } = useTranslation()
const [data, setData] = useState([]) const [data, setData] = useState([])
const [permissions, setPermissions] = useState([]) const [permissions, setPermissions] = useState([])
...@@ -37,7 +37,7 @@ const ToolNotificate = (props) => { ...@@ -37,7 +37,7 @@ const ToolNotificate = (props) => {
theme: 'colored', theme: 'colored',
}) })
} else { } else {
toast.error('Thay đổi trạng thái thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -67,7 +67,7 @@ const ToolNotificate = (props) => { ...@@ -67,7 +67,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy giữ liệu thất bại !', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -92,7 +92,7 @@ const ToolNotificate = (props) => { ...@@ -92,7 +92,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Xoá bản ghi thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -14,12 +14,12 @@ import { Link, useHistory, useLocation } from 'react-router-dom' ...@@ -14,12 +14,12 @@ import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject, toPriceVndInput } from 'app/config/Function' import { trimObject, toPriceVndInput } 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'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([]) const [listDrop, setListDrop] = useState([])
const history = useHistory() const history = useHistory()
const { t } = useTranslation()
const location = useLocation() const location = useLocation()
useEffect(() => { useEffect(() => {
getDropDown() getDropDown()
...@@ -39,7 +39,7 @@ const SimpleForm = (props) => { ...@@ -39,7 +39,7 @@ const SimpleForm = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy thông tin bản ghi thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -59,7 +59,7 @@ const SimpleForm = (props) => { ...@@ -59,7 +59,7 @@ const SimpleForm = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy giữ liệu thất bại !', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -80,7 +80,7 @@ const SimpleForm = (props) => { ...@@ -80,7 +80,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Cập nhật sản phẩm thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -9,9 +9,13 @@ import { Breadcrumb, SimpleCard } from 'app/components' ...@@ -9,9 +9,13 @@ import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom' import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function' import { trimObject } from 'app/config/Function'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const history = useHistory() const history = useHistory()
const { t } = useTranslation()
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() props.showLoading()
...@@ -27,7 +31,7 @@ const SimpleForm = (props) => { ...@@ -27,7 +31,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Tạo loại sản phẩm thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -11,7 +11,7 @@ import { connect } from 'react-redux' ...@@ -11,7 +11,7 @@ import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const searchDebount = useDebounce(txtSearch, 1000) const searchDebount = useDebounce(txtSearch, 1000)
...@@ -24,23 +24,9 @@ const ToolNotificate = (props) => { ...@@ -24,23 +24,9 @@ const ToolNotificate = (props) => {
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
const history = useHistory() const history = useHistory()
const { t } = useTranslation()
const [data, setData] = useState([]) const [data, setData] = useState([])
const [permissions, setPermissions] = 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) => { const handeChangeActive = async (id, status_id) => {
props.showLoading() props.showLoading()
...@@ -52,7 +38,7 @@ const ToolNotificate = (props) => { ...@@ -52,7 +38,7 @@ const ToolNotificate = (props) => {
theme: 'colored', theme: 'colored',
}) })
} else { } else {
toast.error('Thay đổi trạng thái thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -81,7 +67,9 @@ const ToolNotificate = (props) => { ...@@ -81,7 +67,9 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
// enqueueSnackbar('Error!', { variant: 'error' }) toast.error(t(res.data.error), {
theme: 'colored',
})
} }
} }
...@@ -104,7 +92,7 @@ const ToolNotificate = (props) => { ...@@ -104,7 +92,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Xoá bản ghi thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -13,7 +13,7 @@ import { Link, useHistory, useLocation } from 'react-router-dom' ...@@ -13,7 +13,7 @@ import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function' import { trimObject } 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'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const history = useHistory() const history = useHistory()
...@@ -21,7 +21,7 @@ const SimpleForm = (props) => { ...@@ -21,7 +21,7 @@ const SimpleForm = (props) => {
useEffect(() => { useEffect(() => {
getData() getData()
}, []) }, [])
const { t } = useTranslation()
const getData = async () => { const getData = async () => {
props.showLoading() props.showLoading()
const res = await detailProductType(location.state, {}) const res = await detailProductType(location.state, {})
...@@ -34,7 +34,7 @@ const SimpleForm = (props) => { ...@@ -34,7 +34,7 @@ const SimpleForm = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error('Lấy thông tin bản ghi thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -57,7 +57,7 @@ const SimpleForm = (props) => { ...@@ -57,7 +57,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Cập nhật loại sản phẩm thất bại!', { toast.error(t(res.data.error), {
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