mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
save: save reset
appearance: save button reacts to changes
This commit is contained in:
parent
8fcca6587e
commit
7a6776c61b
8 changed files with 36 additions and 18 deletions
|
@ -26,7 +26,7 @@ export const clearAll = () => ({ type: ACTIONS.CLEAR_ALL });
|
|||
export const clearCancel = () => ({ type: ACTIONS.CLEAR_CANCEL });
|
||||
|
||||
export const sendSaveRequest = payload => ({ type: ACTIONS.SEND_SAVE_REQUEST, ...payload });
|
||||
export const cancelSaveRequest = () => ({ type: ACTIONS.CANCEL_SAVE_REQUEST });
|
||||
export const resetSaveDialog = () => ({ type: ACTIONS.RESET_SAVE_DIALOG });
|
||||
|
||||
export const setSaveSuccess = payload => ({ type: ACTIONS.SET_SAVE_SUCCESS, ...payload });
|
||||
export const setSaveError = save_error => ({ type: ACTIONS.SET_SAVE_ERROR, save_error });
|
||||
|
|
|
@ -25,6 +25,7 @@ export const ACTIONS = {
|
|||
|
||||
SEND_SAVE_REQUEST: 'SEND_SAVE_REQUEST',
|
||||
CANCEL_SAVE_REQUEST: 'CANCEL_SAVE_REQUEST',
|
||||
RESET_SAVE_DIALOG: 'RESET_SAVE_DIALOG',
|
||||
|
||||
SET_SAVE_SUCCESS: 'SET_SAVE_SUCCESS',
|
||||
SET_SAVE_ERROR: 'SET_SAVE_ERROR',
|
||||
|
|
|
@ -3,6 +3,7 @@ import { ACTIONS } from '$redux/user/constants';
|
|||
import { DEFAULT_USER } from '$constants/auth';
|
||||
import { MODES } from '$constants/modes';
|
||||
import { DEFAULT_LOGO } from '$constants/logos';
|
||||
import { TIPS } from '$constants/tips';
|
||||
|
||||
const getEstimated = distance => {
|
||||
const time = (distance && (distance / 15)) || 0;
|
||||
|
@ -18,9 +19,7 @@ const setUser = (state, { user }) => ({
|
|||
});
|
||||
|
||||
const setEditing = (state, { editing }) => ({ ...state, editing });
|
||||
const setChanged = (state, { changed }) => ({
|
||||
...state, changed, ...state, save_overwriting: false, save_finished: false, save_processing: false, save_error: '',
|
||||
});
|
||||
const setChanged = (state, { changed }) => ({ ...state, changed });
|
||||
const setMode = (state, { mode }) => ({ ...state, mode });
|
||||
const setDistance = (state, { distance }) => ({
|
||||
...state,
|
||||
|
@ -39,13 +38,19 @@ 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
|
||||
...state, save_overwriting: true, save_finished: false, save_processing: false, save_error: TIPS.SAVE_OVERWRITE,
|
||||
});
|
||||
|
||||
const setSaveSuccess = (state, { save_error }) => ({
|
||||
...state, save_overwriting: false, save_finished: true, save_processing: false, save_error
|
||||
});
|
||||
|
||||
const resetSaveDialog = state => ({
|
||||
...state, save_overwriting: false, save_finished: false, save_processing: false, save_error: '',
|
||||
});
|
||||
|
||||
const HANDLERS = {
|
||||
[ACTIONS.SET_USER]: setUser,
|
||||
[ACTIONS.SET_EDITING]: setEditing,
|
||||
|
@ -62,6 +67,7 @@ const HANDLERS = {
|
|||
[ACTIONS.SET_SAVE_OVERWRITE]: setSaveOverwrite,
|
||||
[ACTIONS.SET_SAVE_SUCCESS]: setSaveSuccess,
|
||||
[ACTIONS.SEND_SAVE_REQUEST]: sendSaveRequest,
|
||||
[ACTIONS.RESET_SAVE_DIALOG]: resetSaveDialog,
|
||||
};
|
||||
|
||||
export const INITIAL_STATE = {
|
||||
|
@ -73,7 +79,7 @@ export const INITIAL_STATE = {
|
|||
distance: 0,
|
||||
estimated: 0,
|
||||
activeSticker: null,
|
||||
title: 0,
|
||||
title: '',
|
||||
address: '',
|
||||
changed: false,
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ function* sendSaveRequestSaga({ title, address, force }) {
|
|||
id, token, route, stickers, title, force, address
|
||||
}),
|
||||
timeout: delay(10000),
|
||||
cancel: take(ACTIONS.CANCEL_SAVE_REQUEST),
|
||||
cancel: take(ACTIONS.RESET_SAVE_DIALOG),
|
||||
});
|
||||
|
||||
if (cancel) return yield put(setMode(MODES.NONE));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue