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