|
|
|
@ -22,7 +22,8 @@ import { LAYER_IDS } from "./Layers/constants";
|
|
|
|
import { Header } from "./Header";
|
|
|
|
import { Header } from "./Header";
|
|
|
|
import { icons } from "../icons/icons-config";
|
|
|
|
import { icons } from "../icons/icons-config";
|
|
|
|
import { LastMLRun } from "./LastMLRun";
|
|
|
|
import { LastMLRun } from "./LastMLRun";
|
|
|
|
import { usePostamatesAndPvzGroups } from "../api.js";
|
|
|
|
import {useOtherGroups, usePostamatesAndPvzGroups} from "../api.js";
|
|
|
|
|
|
|
|
import {transliterate} from "../utils.js";
|
|
|
|
|
|
|
|
|
|
|
|
export const MapComponent = () => {
|
|
|
|
export const MapComponent = () => {
|
|
|
|
const mapRef = useRef(null);
|
|
|
|
const mapRef = useRef(null);
|
|
|
|
@ -35,28 +36,67 @@ export const MapComponent = () => {
|
|
|
|
const { tableState, openTable } = useTable();
|
|
|
|
const { tableState, openTable } = useTable();
|
|
|
|
|
|
|
|
|
|
|
|
const { data: postamatesAndPvzGroups } = usePostamatesAndPvzGroups();
|
|
|
|
const { data: postamatesAndPvzGroups } = usePostamatesAndPvzGroups();
|
|
|
|
|
|
|
|
const { data: otherGroups } = useOtherGroups();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const filteredPostamatesGroups = useMemo(() => {
|
|
|
|
|
|
|
|
if (!postamatesAndPvzGroups) return [];
|
|
|
|
|
|
|
|
return postamatesAndPvzGroups
|
|
|
|
|
|
|
|
.filter((category) => category.visible)
|
|
|
|
|
|
|
|
.map((category) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...category,
|
|
|
|
|
|
|
|
groups: [...category.groups.filter((group) => group.visible)],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}, [postamatesAndPvzGroups]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const filteredOtherGroups = useMemo(() => {
|
|
|
|
|
|
|
|
if (!otherGroups) return [];
|
|
|
|
|
|
|
|
return otherGroups
|
|
|
|
|
|
|
|
.filter((category) => !category.visible)
|
|
|
|
|
|
|
|
.map((category) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...category,
|
|
|
|
|
|
|
|
groups: [...category.groups.filter((group) => group.visible)],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}, [otherGroups]);
|
|
|
|
|
|
|
|
|
|
|
|
const mapIcons = useMemo(() => {
|
|
|
|
const mapIcons = useMemo(() => {
|
|
|
|
if (!postamatesAndPvzGroups) return icons;
|
|
|
|
const res = [];
|
|
|
|
const res = []
|
|
|
|
|
|
|
|
postamatesAndPvzGroups.map((item) => {
|
|
|
|
filteredPostamatesGroups.map((category) => {
|
|
|
|
item.groups.map((groupItem) => {
|
|
|
|
category.groups.map((group) => {
|
|
|
|
res.push({name: groupItem.id, url: groupItem.image})
|
|
|
|
res.push({name: transliterate(group.name + group.id), url: group.image})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filteredOtherGroups.map((category) => {
|
|
|
|
|
|
|
|
category.groups.map((group) => {
|
|
|
|
|
|
|
|
res.push({name: transliterate(group.name + group.id), url: group.image})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return [...res, ...icons];
|
|
|
|
return [...res, ...icons];
|
|
|
|
}, [icons, postamatesAndPvzGroups]);
|
|
|
|
}, [icons, filteredPostamatesGroups, filteredOtherGroups]);
|
|
|
|
|
|
|
|
|
|
|
|
const mapLayersIds = useMemo(() => {
|
|
|
|
const mapLayersIds = useMemo(() => {
|
|
|
|
if (!postamatesAndPvzGroups) return [];
|
|
|
|
|
|
|
|
const res = []
|
|
|
|
const res = []
|
|
|
|
postamatesAndPvzGroups.map((item) => {
|
|
|
|
|
|
|
|
|
|
|
|
filteredPostamatesGroups.map((item) => {
|
|
|
|
item.groups.map((groupItem) => {
|
|
|
|
item.groups.map((groupItem) => {
|
|
|
|
res.push(LAYER_IDS.pvz + groupItem.id);
|
|
|
|
res.push(LAYER_IDS.pvz + groupItem.id);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filteredOtherGroups.map((item) => {
|
|
|
|
|
|
|
|
item.groups.map((groupItem) => {
|
|
|
|
|
|
|
|
res.push(LAYER_IDS.other + groupItem.id);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}, [postamatesAndPvzGroups]);
|
|
|
|
}, [filteredPostamatesGroups, filteredOtherGroups]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
setLayersVisibility(MODE_TO_LAYER_VISIBILITY_MAPPER[mode]);
|
|
|
|
setLayersVisibility(MODE_TO_LAYER_VISIBILITY_MAPPER[mode]);
|
|
|
|
@ -158,7 +198,6 @@ export const MapComponent = () => {
|
|
|
|
LAYER_IDS.filteredWorking,
|
|
|
|
LAYER_IDS.filteredWorking,
|
|
|
|
LAYER_IDS.cancelled,
|
|
|
|
LAYER_IDS.cancelled,
|
|
|
|
...mapLayersIds,
|
|
|
|
...mapLayersIds,
|
|
|
|
LAYER_IDS.other,
|
|
|
|
|
|
|
|
]}
|
|
|
|
]}
|
|
|
|
onClick={handleClick}
|
|
|
|
onClick={handleClick}
|
|
|
|
onMouseEnter={handleMouseEnter}
|
|
|
|
onMouseEnter={handleMouseEnter}
|
|
|
|
@ -192,12 +231,12 @@ export const MapComponent = () => {
|
|
|
|
<SidebarControl toggleCollapse={toggleCollapseSidebar} />
|
|
|
|
<SidebarControl toggleCollapse={toggleCollapseSidebar} />
|
|
|
|
|
|
|
|
|
|
|
|
<Basemap />
|
|
|
|
<Basemap />
|
|
|
|
<Layers postGroups={postamatesAndPvzGroups} />
|
|
|
|
<Layers postGroups={filteredPostamatesGroups} otherGroups={filteredOtherGroups} />
|
|
|
|
|
|
|
|
|
|
|
|
<Legend />
|
|
|
|
<Legend postGroups={filteredPostamatesGroups} otherGroups={filteredOtherGroups} />
|
|
|
|
<LastMLRun />
|
|
|
|
<LastMLRun />
|
|
|
|
<SignOut />
|
|
|
|
<SignOut />
|
|
|
|
<LayersControl postGroups={postamatesAndPvzGroups} />
|
|
|
|
<LayersControl postGroups={filteredPostamatesGroups} otherGroups={filteredOtherGroups} />
|
|
|
|
</Map>
|
|
|
|
</Map>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="w-full border-solid border-border border-0 border-t-[1px] z-20">
|
|
|
|
<div className="w-full border-solid border-border border-0 border-t-[1px] z-20">
|
|
|
|
|