mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
save: save dialog and sagas
This commit is contained in:
parent
b586663827
commit
8fcca6587e
10 changed files with 161 additions and 88 deletions
|
@ -18,7 +18,9 @@ const setUser = (state, { user }) => ({
|
|||
});
|
||||
|
||||
const setEditing = (state, { editing }) => ({ ...state, editing });
|
||||
const setChanged = (state, { changed }) => ({ ...state, changed });
|
||||
const setChanged = (state, { changed }) => ({
|
||||
...state, changed, ...state, save_overwriting: false, save_finished: false, save_processing: false, save_error: '',
|
||||
});
|
||||
const setMode = (state, { mode }) => ({ ...state, mode });
|
||||
const setDistance = (state, { distance }) => ({
|
||||
...state,
|
||||
|
@ -33,6 +35,17 @@ const setLogo = (state, { logo }) => ({ ...state, logo });
|
|||
const setTitle = (state, { title }) => ({ ...state, title });
|
||||
const setAddress = (state, { address }) => ({ ...state, address });
|
||||
|
||||
const sendSaveRequest = state => ({ ...state, save_processing: true, });
|
||||
const setSaveError = (state, { save_error }) => ({
|
||||
...state, save_error, save_finished: false, save_processing: false
|
||||
});
|
||||
const setSaveOverwrite = state => ({
|
||||
...state, save_overwriting: true, save_finished: false, save_processing: false
|
||||
});
|
||||
const setSaveSuccess = (state, { save_error }) => ({
|
||||
...state, save_overwriting: false, save_finished: true, save_processing: false, save_error
|
||||
});
|
||||
|
||||
const HANDLERS = {
|
||||
[ACTIONS.SET_USER]: setUser,
|
||||
[ACTIONS.SET_EDITING]: setEditing,
|
||||
|
@ -44,6 +57,11 @@ const HANDLERS = {
|
|||
[ACTIONS.SET_LOGO]: setLogo,
|
||||
[ACTIONS.SET_TITLE]: setTitle,
|
||||
[ACTIONS.SET_ADDRESS]: setAddress,
|
||||
|
||||
[ACTIONS.SET_SAVE_ERROR]: setSaveError,
|
||||
[ACTIONS.SET_SAVE_OVERWRITE]: setSaveOverwrite,
|
||||
[ACTIONS.SET_SAVE_SUCCESS]: setSaveSuccess,
|
||||
[ACTIONS.SEND_SAVE_REQUEST]: sendSaveRequest,
|
||||
};
|
||||
|
||||
export const INITIAL_STATE = {
|
||||
|
@ -58,6 +76,11 @@ export const INITIAL_STATE = {
|
|||
title: 0,
|
||||
address: '',
|
||||
changed: false,
|
||||
|
||||
save_error: '',
|
||||
save_finished: false,
|
||||
save_overwriting: false,
|
||||
save_processing: false,
|
||||
};
|
||||
|
||||
export const userReducer = createReducer(INITIAL_STATE, HANDLERS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue