Commit be49e123 by tdgiang

update code

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