renamed some map actions from user

This commit is contained in:
Fedor Katurov 2020-01-08 11:44:27 +07:00
parent de5726929f
commit aa8fd14517
5 changed files with 28 additions and 26 deletions

View file

@ -2,14 +2,14 @@ import * as React from 'react';
import { PROVIDERS, replaceProviderUrl } from '$constants/providers'; import { PROVIDERS, replaceProviderUrl } from '$constants/providers';
import { Icon } from '$components/panels/Icon'; import { Icon } from '$components/panels/Icon';
import classnames from 'classnames'; import classnames from 'classnames';
import { changeProvider as changeProviderAction } from "$redux/user/actions"; import * as MAP_ACTIONS from "$redux/map/actions";
import { IRootState } from "$redux/user"; import { IRootState } from "$redux/user";
interface Props extends IRootState { interface Props extends IRootState {
changeProvider: typeof changeProviderAction, mapSetProvider: typeof MAP_ACTIONS.mapSetProvider,
} }
export const ProviderDialog = ({ provider, changeProvider }: Props) => ( export const ProviderDialog = ({ provider, mapSetProvider }: Props) => (
<div className="control-dialog top right control-dialog-provider"> <div className="control-dialog top right control-dialog-provider">
<div className="helper provider-helper"> <div className="helper provider-helper">
{ {
@ -19,7 +19,7 @@ export const ProviderDialog = ({ provider, changeProvider }: Props) => (
style={{ style={{
backgroundImage: `url(${replaceProviderUrl(item, { x: 5980, y: 2589, zoom: 13 })})`, backgroundImage: `url(${replaceProviderUrl(item, { x: 5980, y: 2589, zoom: 13 })})`,
}} }}
onMouseDown={() => changeProvider(item)} onMouseDown={() => mapSetProvider(item)}
key={PROVIDERS[item].name} key={PROVIDERS[item].name}
> >
{ {

View file

@ -199,4 +199,4 @@ const Sticker: React.FC<IProps> = ({
); );
}; };
export { Sticker }; export { Sticker };

View file

@ -8,21 +8,23 @@ import { DEFAULT_LOGO, ILogos, LOGOS } from '$constants/logos';
import { getUrlData } from '$utils/history'; import { getUrlData } from '$utils/history';
import { store } from '$redux/store'; import { store } from '$redux/store';
import { import {
changeProvider,
resetSaveDialog, resetSaveDialog,
setActiveSticker, setActiveSticker,
setAddress,
setChanged, setChanged,
setDescription,
setDistance, setDistance,
setIsEmpty, setIsRouting, setIsEmpty, setIsRouting,
setLogo,
setMarkersShown, setMarkersShown,
setMode, setMode,
setPublic,
setRouterPoints, setStarred, setRouterPoints, setStarred,
setTitle,
} from '$redux/user/actions'; } from '$redux/user/actions';
import {
mapSetAddress,
mapSetDescription,
mapSetLogo,
mapSetPublic,
mapSetTitle,
mapSetProvider,
} from '$redux/map/actions';
import { DEFAULT_PROVIDER, IProvider, PROVIDERS } from '$constants/providers'; import { DEFAULT_PROVIDER, IProvider, PROVIDERS } from '$constants/providers';
import { STICKERS } from '$constants/stickers'; import { STICKERS } from '$constants/stickers';
import { IRootState } from "$redux/user"; import { IRootState } from "$redux/user";
@ -184,14 +186,14 @@ export class Editor {
getDistance = () => this.getState().distance; getDistance = () => this.getState().distance;
getIsEmpty = () => this.getState().is_empty; getIsEmpty = () => this.getState().is_empty;
setLogo: typeof setLogo = logo => store.dispatch(setLogo(logo)); mapSetLogo: typeof mapSetLogo = logo => store.dispatch(mapSetLogo(logo));
setMode: typeof setMode = value => store.dispatch(setMode(value)); setMode: typeof setMode = value => store.dispatch(setMode(value));
setRouterPoints: typeof setRouterPoints = value => store.dispatch(setRouterPoints(value)); setRouterPoints: typeof setRouterPoints = value => store.dispatch(setRouterPoints(value));
setActiveSticker: typeof setActiveSticker = value => store.dispatch(setActiveSticker(value)); setActiveSticker: typeof setActiveSticker = value => store.dispatch(setActiveSticker(value));
setTitle: typeof setTitle = value => store.dispatch(setTitle(value)); mapSetTitle: typeof mapSetTitle = value => store.dispatch(mapSetTitle(value));
setDescription: typeof setDescription = value => store.dispatch(setDescription(value)); mapSetDescription: typeof mapSetDescription = value => store.dispatch(mapSetDescription(value));
setAddress: typeof setAddress = value => store.dispatch(setAddress(value)); mapSetAddress: typeof mapSetAddress = value => store.dispatch(mapSetAddress(value));
setPublic: typeof setPublic = value => store.dispatch(setPublic(value)); mapSetPublic: typeof mapSetPublic = value => store.dispatch(mapSetPublic(value));
setStarred: typeof setStarred = value => store.dispatch(setStarred(value)); setStarred: typeof setStarred = value => store.dispatch(setStarred(value));
setIsEmpty: typeof setIsEmpty = value => store.dispatch(setIsEmpty(value)); setIsEmpty: typeof setIsEmpty = value => store.dispatch(setIsEmpty(value));
setIsRouting: typeof setIsRouting = value => store.dispatch(setIsRouting(value)); setIsRouting: typeof setIsRouting = value => store.dispatch(setIsRouting(value));
@ -324,11 +326,11 @@ export class Editor {
is_published, is_published,
description, description,
}: Partial<IEditor['initialData']>): void => { }: Partial<IEditor['initialData']>): void => {
this.setTitle(title || ''); this.mapSetTitle(title || '');
const { id } = this.getUser(); const { id } = this.getUser();
if (address && id && owner && id === owner) { if (address && id && owner && id === owner) {
this.setAddress(address); this.mapSetAddress(address);
} }
if (route) this.poly.setPoints(route); if (route) this.poly.setPoints(route);
@ -348,11 +350,11 @@ export class Editor {
); );
} }
this.setPublic(is_public); this.mapSetPublic(is_public);
this.setStarred(is_published); this.setStarred(is_published);
this.setDescription(description); this.mapSetDescription(description);
this.setLogo((logo && LOGOS[DEFAULT_LOGO] && logo) || DEFAULT_LOGO); this.mapSetLogo((logo && LOGOS[DEFAULT_LOGO] && logo) || DEFAULT_LOGO);
this.setProvider((provider && PROVIDERS[provider] && provider) || DEFAULT_PROVIDER); this.setProvider((provider && PROVIDERS[provider] && provider) || DEFAULT_PROVIDER);
if (owner) this.owner = owner; if (owner) this.owner = owner;
@ -438,7 +440,7 @@ export class Editor {
provider: this.getProvider(), provider: this.getProvider(),
}); });
setProvider: typeof changeProvider = provider => store.dispatch(changeProvider(provider)); setProvider: typeof mapSetProvider = provider => store.dispatch(mapSetProvider(provider));
get isEmpty(): boolean { get isEmpty(): boolean {
const { route, stickers } = this.dumpData(); const { route, stickers } = this.dumpData();

View file

@ -63,8 +63,8 @@ export const setRenderer = payload => ({ type: USER_ACTIONS.SET_RENDERER, payloa
export const takeAShot = () => ({ type: USER_ACTIONS.TAKE_A_SHOT }); export const takeAShot = () => ({ type: USER_ACTIONS.TAKE_A_SHOT });
export const cropAShot = payload => ({ type: USER_ACTIONS.CROP_A_SHOT, ...payload }); export const cropAShot = payload => ({ type: USER_ACTIONS.CROP_A_SHOT, ...payload });
export const setProvider = provider => ({ type: USER_ACTIONS.SET_PROVIDER, provider }); // export const setProvider = provider => ({ type: USER_ACTIONS.SET_PROVIDER, provider });
export const changeProvider = provider => ({ type: USER_ACTIONS.CHANGE_PROVIDER, provider }); // export const changeProvider = provider => ({ type: USER_ACTIONS.CHANGE_PROVIDER, provider });
export const setDialog = dialog => ({ type: USER_ACTIONS.SET_DIALOG, dialog }); export const setDialog = dialog => ({ type: USER_ACTIONS.SET_DIALOG, dialog });
export const setDialogActive = dialog_active => ({ type: USER_ACTIONS.SET_DIALOG_ACTIVE, dialog_active }); export const setDialogActive = dialog_active => ({ type: USER_ACTIONS.SET_DIALOG_ACTIVE, dialog_active });

View file

@ -121,7 +121,7 @@ const setRenderer: ActionHandler<typeof ActionCreators.setRenderer> = (state, {
renderer: { ...state.renderer, ...payload } renderer: { ...state.renderer, ...payload }
}); });
const setProvider: ActionHandler<typeof ActionCreators.setProvider> = (state, { provider }) => ({ ...state, provider }); // const setProvider: ActionHandler<typeof ActionCreators.setProvider> = (state, { provider }) => ({ ...state, provider });
const setDialog: ActionHandler<typeof ActionCreators.setDialog> = (state, { dialog }) => ({ const setDialog: ActionHandler<typeof ActionCreators.setDialog> = (state, { dialog }) => ({
...state, ...state,
@ -270,7 +270,7 @@ export const USER_HANDLERS = ({
[USER_ACTIONS.HIDE_RENDERER]: hideRenderer, [USER_ACTIONS.HIDE_RENDERER]: hideRenderer,
[USER_ACTIONS.SET_RENDERER]: setRenderer, [USER_ACTIONS.SET_RENDERER]: setRenderer,
[USER_ACTIONS.SET_PROVIDER]: setProvider, // [USER_ACTIONS.SET_PROVIDER]: setProvider,
[USER_ACTIONS.SET_DIALOG]: setDialog, [USER_ACTIONS.SET_DIALOG]: setDialog,
[USER_ACTIONS.SET_DIALOG_ACTIVE]: setDialogActive, [USER_ACTIONS.SET_DIALOG_ACTIVE]: setDialogActive,