mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-05-03 23:16:40 +07:00
passing editing status to map
This commit is contained in:
parent
58eefd5670
commit
9c3c8cf46d
10 changed files with 213 additions and 65 deletions
src/containers/map/Map
|
@ -1,30 +1,46 @@
|
|||
import { Map as MapInterface, map } from "leaflet";
|
||||
import * as React from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { MapContext } from "$utils/context.ts";
|
||||
import { selectMapProvider, selectMapRoute, selectMapStickers } from "$redux/map/selectors";
|
||||
import {
|
||||
selectMapProvider,
|
||||
selectMapRoute,
|
||||
selectMapStickers
|
||||
} from "$redux/map/selectors";
|
||||
import { connect } from "react-redux";
|
||||
import * as MAP_ACTIONS from "$redux/map/actions";
|
||||
|
||||
import { Route } from "$containers/map/Route";
|
||||
import { TileLayer } from "$containers/map/TileLayer";
|
||||
import { Stickers } from "$containers/map/Stickers";
|
||||
import { selectUserEditing } from '$redux/user/selectors'
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
provider: selectMapProvider(state),
|
||||
route: selectMapRoute(state),
|
||||
stickers: selectMapStickers(state),
|
||||
editing: selectUserEditing(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
mapSetRoute: MAP_ACTIONS.mapSetRoute
|
||||
mapSetRoute: MAP_ACTIONS.mapSetRoute,
|
||||
mapDropSticker: MAP_ACTIONS.mapDropSticker,
|
||||
mapSetSticker: MAP_ACTIONS.mapSetSticker
|
||||
};
|
||||
|
||||
type IProps = React.HTMLAttributes<HTMLDivElement> &
|
||||
ReturnType<typeof mapStateToProps> &
|
||||
typeof mapDispatchToProps & {};
|
||||
|
||||
const MapUnconnected: React.FC<IProps> = ({ provider, route, mapSetRoute, stickers }) => {
|
||||
const MapUnconnected: React.FC<IProps> = ({
|
||||
provider,
|
||||
route,
|
||||
stickers,
|
||||
editing,
|
||||
|
||||
mapSetRoute,
|
||||
mapSetSticker,
|
||||
mapDropSticker
|
||||
}) => {
|
||||
const ref = React.useRef(null);
|
||||
const [maps, setMaps] = React.useState<MapInterface>(null);
|
||||
|
||||
|
@ -34,13 +50,17 @@ const MapUnconnected: React.FC<IProps> = ({ provider, route, mapSetRoute, sticke
|
|||
setMaps(map(ref.current).setView([55.0153275, 82.9071235], 13));
|
||||
}, [ref]);
|
||||
|
||||
// console.log('RERENDER!');
|
||||
|
||||
return createPortal(
|
||||
<div ref={ref}>
|
||||
<TileLayer provider={provider} map={maps} />
|
||||
<Route route={route} mapSetRoute={mapSetRoute} map={maps} is_editing />
|
||||
<Stickers stickers={stickers} map={maps} is_editing />
|
||||
<TileLayer provider={provider} map={maps} />
|
||||
<Route route={route} mapSetRoute={mapSetRoute} map={maps} is_editing={editing} />
|
||||
<Stickers
|
||||
stickers={stickers}
|
||||
map={maps}
|
||||
mapSetSticker={mapSetSticker}
|
||||
mapDropSticker={mapDropSticker}
|
||||
is_editing={editing}
|
||||
/>
|
||||
</div>,
|
||||
document.getElementById("canvas")
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue