mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
adding stickers on click
This commit is contained in:
parent
e0048d1fc3
commit
6db2809de5
11 changed files with 83 additions and 20 deletions
40
src/redux/map/sagas.ts
Normal file
40
src/redux/map/sagas.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { takeEvery, select, put } from "redux-saga/effects";
|
||||
import { MAP_ACTIONS } from "./constants";
|
||||
import { mapClicked, mapSet } from "./actions";
|
||||
import { selectUserMode, selectUserActiveSticker } from "$redux/user/selectors";
|
||||
import { IRootReducer } from "$redux/user";
|
||||
import { MODES } from "$constants/modes";
|
||||
import { selectMapStickers } from "./selectors";
|
||||
import { setActiveSticker, setMode } from "$redux/user/actions";
|
||||
|
||||
function* onMapClick({ latlng }: ReturnType<typeof mapClicked>) {
|
||||
const mode = yield select(selectUserMode);
|
||||
const { set, sticker } = yield select(selectUserActiveSticker);
|
||||
const stickers = yield select(selectMapStickers);
|
||||
|
||||
switch (mode) {
|
||||
case MODES.STICKERS:
|
||||
yield put(
|
||||
mapSet({
|
||||
stickers: [
|
||||
...stickers,
|
||||
{
|
||||
latlng,
|
||||
set,
|
||||
sticker,
|
||||
text: "",
|
||||
angle: 0,
|
||||
}
|
||||
]
|
||||
})
|
||||
);
|
||||
yield put(setMode(MODES.NONE))
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
export function* mapSaga() {
|
||||
yield takeEvery(MAP_ACTIONS.MAP_CLICKED, onMapClick);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue