mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Refacto onChange action
This commit is contained in:
parent
97d6f49f93
commit
405272eadf
@ -55,7 +55,7 @@ export function fetchDataSucceeded(data) {
|
||||
export function onChange({ target }) {
|
||||
return {
|
||||
type: ON_CHANGE,
|
||||
key: target.name,
|
||||
keys: ['modifiedData'].concat(target.name.split('.')),
|
||||
value: target.value,
|
||||
};
|
||||
}
|
||||
|
@ -129,12 +129,7 @@ export class HomePage extends React.Component {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
this.props.submit(match.params.settingType);
|
||||
}}
|
||||
>
|
||||
<form onSubmit={(e) => e.preventDefault()}>
|
||||
<div className={cn('container-fluid', styles.containerFluid)}>
|
||||
<PluginHeader
|
||||
title={{ id: 'users-permissions.HomePage.header.title' }}
|
||||
|
@ -42,7 +42,7 @@ function homePageReducer(state = initialState, action) {
|
||||
return state.set('data', List(action.data));
|
||||
case ON_CHANGE:
|
||||
return state
|
||||
.updateIn(['modifiedData', action.key], () => action.value);
|
||||
.updateIn(action.keys, () => action.value);
|
||||
case SET_FORM:
|
||||
return state
|
||||
.set('initialData', action.form)
|
||||
|
@ -67,11 +67,10 @@ export function* submitData(action) {
|
||||
try {
|
||||
const body = yield select(makeSelectModifiedData());
|
||||
const opts = { method: 'PUT', body };
|
||||
const response = yield call(request, `/users-permissions/${action.endPoint}`, opts, true);
|
||||
|
||||
if (response.ok) {
|
||||
yield put(submitSucceeded());
|
||||
}
|
||||
yield call(request, `/users-permissions/${action.endPoint}`, opts, true);
|
||||
yield put(submitSucceeded());
|
||||
|
||||
} catch(error) {
|
||||
strapi.notification.error('notification.error');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user