diff --git a/frontend/app/components/Client/Roles/Roles.tsx b/frontend/app/components/Client/Roles/Roles.tsx index 848e9fea0..e8b0fe9e9 100644 --- a/frontend/app/components/Client/Roles/Roles.tsx +++ b/frontend/app/components/Client/Roles/Roles.tsx @@ -4,7 +4,7 @@ import { Loader, IconButton, Popup, NoContent, SlideModal } from 'UI' import { connect } from 'react-redux' import stl from './roles.css' import RoleForm from './components/RoleForm' -import { init, edit, fetchList, remove as deleteRole } from 'Duck/roles'; +import { init, edit, fetchList, remove as deleteRole, resetErrors } from 'Duck/roles'; import RoleItem from './components/RoleItem' import { confirm } from 'UI/Confirmation'; import { toast } from 'react-toastify'; @@ -19,7 +19,8 @@ interface Props { fetchList: () => Promise, account: any, permissionsMap: any, - removeErrors: any + removeErrors: any, + resetErrors: () => void } function Roles(props: Props) { @@ -37,6 +38,9 @@ function Roles(props: Props) { toast.error(e) }) } + return () => { + props.resetErrors() + } }, [removeErrors]) const closeModal = () => { @@ -134,4 +138,4 @@ export default connect(state => { loading: state.getIn(['roles', 'fetchRequest', 'loading']), account: state.getIn([ 'user', 'account' ]) } -}, { init, edit, fetchList, deleteRole })(Roles) \ No newline at end of file +}, { init, edit, fetchList, deleteRole, resetErrors })(Roles) \ No newline at end of file diff --git a/frontend/app/duck/roles.js b/frontend/app/duck/roles.js index 67c9a79df..874bd9be6 100644 --- a/frontend/app/duck/roles.js +++ b/frontend/app/duck/roles.js @@ -6,6 +6,8 @@ import { reduceDucks } from 'Duck/tools'; const crudDuck = crudDuckGenerator('client/role', Role, { idKey: 'roleId' }); export const { fetchList, init, edit, remove, } = crudDuck.actions; +const RESET_ERRORS = 'roles/RESET_ERRORS'; + const initialState = Map({ list: List(), permissions: List([ @@ -19,6 +21,10 @@ const initialState = Map({ }); const reducer = (state = initialState, action = {}) => { + switch (action.type) { + case RESET_ERRORS: + return state.setIn(['removeRequest', 'errors'], null); + } return state; }; @@ -29,4 +35,10 @@ export function save(instance) { }; } +export function resetErrors() { + return { + type: RESET_ERRORS, + } +} + export default reduceDucks(crudDuck, { initialState, reducer }).reducer;