mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
routes: interface initial
This commit is contained in:
parent
2cfd9067a9
commit
d11dd9043c
9 changed files with 214 additions and 7 deletions
|
@ -32,7 +32,6 @@ export const setSaveSuccess = payload => ({ type: ACTIONS.SET_SAVE_SUCCESS, ...p
|
|||
export const setSaveError = save_error => ({ type: ACTIONS.SET_SAVE_ERROR, save_error });
|
||||
export const setSaveOverwrite = () => ({ type: ACTIONS.SET_SAVE_OVERWRITE });
|
||||
|
||||
export const showRenderer = () => ({ type: ACTIONS.SHOW_RENDERER });
|
||||
export const hideRenderer = () => ({ type: ACTIONS.HIDE_RENDERER });
|
||||
export const setRenderer = payload => ({ type: ACTIONS.SET_RENDERER, payload });
|
||||
export const takeAShot = () => ({ type: ACTIONS.TAKE_A_SHOT });
|
||||
|
@ -49,4 +48,6 @@ export const setReady = ready => ({ type: ACTIONS.SET_READY, ready });
|
|||
export const gotVkUser = user => ({ type: ACTIONS.GOT_VK_USER, user });
|
||||
export const keyPressed = ({ key }) => ({ type: ACTIONS.KEY_PRESSED, key });
|
||||
|
||||
export const iframeLoginVk = payload => ({ type: ACTIONS.IFRAME_LOGIN_VK, ...payload });
|
||||
export const searchSetTitle = title => ({ type: ACTIONS.SEARCH_SET_TITLE, title });
|
||||
export const searchSetDistance = distance => ({ type: ACTIONS.SEARCH_SET_DISTANCE, distance });
|
||||
export const searchSetTab = tab => ({ type: ACTIONS.SEARCH_SET_TAB, tab });
|
||||
|
|
|
@ -50,4 +50,9 @@ export const ACTIONS = ({
|
|||
KEY_PRESSED: 'KEY_PRESSED',
|
||||
|
||||
IFRAME_LOGIN_VK: 'IFRAME_LOGIN_VK',
|
||||
|
||||
SEARCH_SET_TITLE: 'SEARCH_SET_TITLE',
|
||||
SEARCH_SET_DISTANCE: 'SEARCH_SET_DISTANCE',
|
||||
|
||||
SEARCH_SET_TAB: 'SEARCH_SET_TAB',
|
||||
}: { [key: String]: String });
|
||||
|
|
|
@ -95,6 +95,39 @@ const setReady = (state, { ready = true }) => ({
|
|||
ready,
|
||||
});
|
||||
|
||||
const searchSetTitle = (state, { title = '' }) => ({
|
||||
...state,
|
||||
routes: {
|
||||
...state.routes,
|
||||
filter: {
|
||||
...state.routes.filter,
|
||||
title,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const searchSetDistance = (state, { distance = [0, 9999] }) => ({
|
||||
...state,
|
||||
routes: {
|
||||
...state.routes,
|
||||
filter: {
|
||||
...state.routes.filter,
|
||||
distance,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const searchSetTab = (state, { tab = 'mine' }) => ({
|
||||
...state,
|
||||
routes: {
|
||||
...state.routes,
|
||||
filter: {
|
||||
...state.routes.filter,
|
||||
tab: ['mine', 'all', 'star'].indexOf(tab) >= 0 ? tab : 'mine',
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const HANDLERS = ({
|
||||
[ACTIONS.SET_USER]: setUser,
|
||||
[ACTIONS.SET_EDITING]: setEditing,
|
||||
|
@ -122,6 +155,10 @@ const HANDLERS = ({
|
|||
[ACTIONS.SET_DIALOG]: setDialog,
|
||||
[ACTIONS.SET_DIALOG_ACTIVE]: setDialogActive,
|
||||
[ACTIONS.SET_READY]: setReady,
|
||||
|
||||
[ACTIONS.SEARCH_SET_TITLE]: searchSetTitle,
|
||||
[ACTIONS.SEARCH_SET_DISTANCE]: searchSetDistance,
|
||||
[ACTIONS.SEARCH_SET_TAB]: searchSetTab,
|
||||
}: { [key: String]: Function });
|
||||
|
||||
export const INITIAL_STATE = {
|
||||
|
@ -145,8 +182,8 @@ export const INITIAL_STATE = {
|
|||
save_overwriting: false,
|
||||
save_processing: false,
|
||||
|
||||
dialog: DIALOGS.NONE,
|
||||
dialog_active: false,
|
||||
dialog: DIALOGS.MAP_LIST,
|
||||
dialog_active: true,
|
||||
|
||||
renderer: {
|
||||
data: '',
|
||||
|
@ -155,7 +192,21 @@ export const INITIAL_STATE = {
|
|||
renderer_active: false,
|
||||
info: '',
|
||||
progress: 0,
|
||||
}
|
||||
},
|
||||
|
||||
routes: {
|
||||
limit: 0,
|
||||
loading: false, // <-- maybe delete this
|
||||
list: [],
|
||||
filter: {
|
||||
title: '',
|
||||
starred: false,
|
||||
distance: [0, 300],
|
||||
|
||||
author: '',
|
||||
tab: 'mine',
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const userReducer = createReducer(INITIAL_STATE, HANDLERS);
|
||||
|
|
|
@ -435,6 +435,13 @@ function* keyPressedSaga({ key }): void {
|
|||
return;
|
||||
}
|
||||
|
||||
function* searchSetSaga() {
|
||||
yield delay(500);
|
||||
const { routes: { filter: { title, distance, tab }}} = yield select(getState);
|
||||
|
||||
console.log({ title, distance, tab });
|
||||
}
|
||||
|
||||
export function* userSaga() {
|
||||
yield takeLatest(REHYDRATE, authCheckSaga);
|
||||
yield takeEvery(ACTIONS.SET_MODE, setModeSaga);
|
||||
|
@ -467,4 +474,9 @@ export function* userSaga() {
|
|||
yield takeLatest(ACTIONS.KEY_PRESSED, keyPressedSaga);
|
||||
|
||||
yield takeLatest(ACTIONS.IFRAME_LOGIN_VK, iframeLoginVkSaga);
|
||||
|
||||
yield takeLatest([
|
||||
ACTIONS.SEARCH_SET_TITLE,
|
||||
ACTIONS.SEARCH_SET_DISTANCE,
|
||||
], searchSetSaga)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue