Commit be49e123 by tdgiang

update code

parent 2c69692f
...@@ -25,7 +25,7 @@ import { ...@@ -25,7 +25,7 @@ import {
} from 'app/apis/Functions/dropdown' } from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage' import PickerImage from 'app/components/Input/PickerImage'
import { actionByGroup, createEmployee } from 'app/apis/Functions/Employee' import { actionByGroup, createEmployee } from 'app/apis/Functions/Employee'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const [listDepartment, setListDepartment] = useState([]) const [listDepartment, setListDepartment] = useState([])
...@@ -36,6 +36,8 @@ const SimpleForm = (props) => { ...@@ -36,6 +36,8 @@ const SimpleForm = (props) => {
const [role, setRole] = useState() const [role, setRole] = useState()
const [listGroup, setGroup] = useState([]) const [listGroup, setGroup] = useState([])
const [checkAll, setCheckAll] = useState(true) const [checkAll, setCheckAll] = useState(true)
const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getUserGroup() getUserGroup()
}, []) }, [])
...@@ -56,7 +58,7 @@ const SimpleForm = (props) => { ...@@ -56,7 +58,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',
}) })
} }
...@@ -73,7 +75,7 @@ const SimpleForm = (props) => { ...@@ -73,7 +75,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',
}) })
} }
...@@ -105,7 +107,7 @@ const SimpleForm = (props) => { ...@@ -105,7 +107,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Tạo nhân viên thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -11,6 +11,8 @@ import { connect } from 'react-redux' ...@@ -11,6 +11,8 @@ 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)
...@@ -21,7 +23,7 @@ const ToolNotificate = (props) => { ...@@ -21,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([])
// useEffect(() => { // useEffect(() => {
...@@ -49,7 +51,7 @@ const ToolNotificate = (props) => { ...@@ -49,7 +51,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',
}) })
} }
...@@ -76,7 +78,9 @@ const ToolNotificate = (props) => { ...@@ -76,7 +78,9 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
// enqueueSnackbar('Error!', { variant: 'error' }) toast.error(t(res.data.error), {
theme: 'colored',
})
} }
} catch (error) {} } catch (error) {}
} }
...@@ -100,7 +104,7 @@ const ToolNotificate = (props) => { ...@@ -100,7 +104,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',
}) })
} }
......
...@@ -31,6 +31,7 @@ import { ...@@ -31,6 +31,7 @@ import {
detailEmployee, detailEmployee,
updateEmployee, updateEmployee,
} from 'app/apis/Functions/Employee' } from 'app/apis/Functions/Employee'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
...@@ -44,6 +45,8 @@ const SimpleForm = (props) => { ...@@ -44,6 +45,8 @@ const SimpleForm = (props) => {
const [checkAll, setCheckAll] = useState(true) const [checkAll, setCheckAll] = useState(true)
const location = useLocation() const location = useLocation()
const [defaultAction, setDefaultAction] = useState([]) const [defaultAction, setDefaultAction] = useState([])
const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getUserGroup() getUserGroup()
getData() getData()
...@@ -94,7 +97,7 @@ const SimpleForm = (props) => { ...@@ -94,7 +97,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',
}) })
} }
...@@ -111,7 +114,7 @@ const SimpleForm = (props) => { ...@@ -111,7 +114,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',
}) })
} }
...@@ -142,7 +145,7 @@ const SimpleForm = (props) => { ...@@ -142,7 +145,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Tạo nhân viên thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -9,8 +9,11 @@ import { Breadcrumb, SimpleCard } from 'app/components' ...@@ -9,8 +9,11 @@ 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 { t } = useTranslation()
const history = useHistory() const history = useHistory()
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
...@@ -29,7 +32,7 @@ const SimpleForm = (props) => { ...@@ -29,7 +32,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Tạo hành động thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -11,11 +11,11 @@ import { connect } from 'react-redux' ...@@ -11,11 +11,11 @@ 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)
const { t } = useTranslation()
const [activeSelected, setActiveSeleted] = useState(null) const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1) const [changeActive, setChangeActive] = useState(1)
...@@ -52,7 +52,7 @@ const ToolNotificate = (props) => { ...@@ -52,7 +52,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',
}) })
} }
...@@ -82,7 +82,9 @@ const ToolNotificate = (props) => { ...@@ -82,7 +82,9 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
// enqueueSnackbar('Error!', { variant: 'error' }) toast.error(t(res.data.error), {
theme: 'colored',
})
} }
} }
...@@ -105,7 +107,7 @@ const ToolNotificate = (props) => { ...@@ -105,7 +107,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',
}) })
} }
......
...@@ -10,11 +10,13 @@ import { Link, useHistory, useLocation } from 'react-router-dom' ...@@ -10,11 +10,13 @@ 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()
const location = useLocation() const location = useLocation()
const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getData() getData()
}, []) }, [])
...@@ -31,7 +33,7 @@ const SimpleForm = (props) => { ...@@ -31,7 +33,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',
}) })
} }
...@@ -54,7 +56,7 @@ const SimpleForm = (props) => { ...@@ -54,7 +56,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',
}) })
} }
......
...@@ -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)
...@@ -20,25 +20,11 @@ const ToolNotificate = (props) => { ...@@ -20,25 +20,11 @@ const ToolNotificate = (props) => {
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 { t } = useTranslation()
const history = useHistory() const history = useHistory()
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()
...@@ -50,7 +36,7 @@ const ToolNotificate = (props) => { ...@@ -50,7 +36,7 @@ const ToolNotificate = (props) => {
theme: 'colored', theme: 'colored',
}) })
} else { } else {
toast.success('Thay đổi trạng thái thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -80,7 +66,7 @@ const ToolNotificate = (props) => { ...@@ -80,7 +66,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',
}) })
} }
...@@ -105,7 +91,7 @@ const ToolNotificate = (props) => { ...@@ -105,7 +91,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',
}) })
} }
......
...@@ -32,11 +32,13 @@ import { trimObject } from 'app/config/Function' ...@@ -32,11 +32,13 @@ import { trimObject } 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 { createAction } from 'app/apis/Functions/action' import { createAction } from 'app/apis/Functions/action'
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()
}, []) }, [])
...@@ -74,7 +76,7 @@ const SimpleForm = (props) => { ...@@ -74,7 +76,7 @@ const SimpleForm = (props) => {
}) })
} }
} else { } else {
toast.error('Tạo hành động thất bại!', { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -11,13 +11,13 @@ import { connect } from 'react-redux' ...@@ -11,13 +11,13 @@ 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)
const [changeActive, setChangeActive] = useState(1) const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000) const searchDebount = useDebounce(txtSearch, 1000)
const { t } = useTranslation()
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)
...@@ -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 } 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 [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',
}) })
} }
...@@ -54,7 +54,7 @@ const SimpleForm = (props) => { ...@@ -54,7 +54,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',
}) })
} }
......
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