|
|
|
|
@ -9,17 +9,20 @@ import { WorkingPointPopup } from "./mode-popup/WorkingPointPopup";
|
|
|
|
|
import { FeatureProperties } from "./mode-popup/FeatureProperties";
|
|
|
|
|
import { usePopup } from "../../stores/usePopup.js";
|
|
|
|
|
import { PanoramaIcon } from "../../icons/PanoramaIcon";
|
|
|
|
|
import {usePostamatesAndPvzGroups} from "../../api.js";
|
|
|
|
|
import {useMemo} from "react";
|
|
|
|
|
|
|
|
|
|
const SingleFeaturePopup = ({ feature }) => {
|
|
|
|
|
const SingleFeaturePopup = ({ feature, groups, categories }) => {
|
|
|
|
|
const { mode } = useMode();
|
|
|
|
|
const isRivals =
|
|
|
|
|
feature.layer?.id === LAYER_IDS.pvz ||
|
|
|
|
|
feature.layer?.id === LAYER_IDS.other;
|
|
|
|
|
feature.layer?.id === LAYER_IDS.other ||
|
|
|
|
|
feature.layer?.id.includes(LAYER_IDS.pvz);
|
|
|
|
|
const isPendingPoint = feature.properties.status === STATUSES.pending;
|
|
|
|
|
const isWorkingPoint = feature.properties.status === STATUSES.working;
|
|
|
|
|
|
|
|
|
|
if (isRivals) {
|
|
|
|
|
return <FeatureProperties feature={feature} />;
|
|
|
|
|
return <FeatureProperties feature={feature} groups={groups} categories={categories} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mode === MODES.ON_APPROVAL && !isPendingPoint) {
|
|
|
|
|
@ -36,7 +39,7 @@ const SingleFeaturePopup = ({ feature }) => {
|
|
|
|
|
return <FeatureProperties feature={feature} />;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const MultipleFeaturesPopup = ({ features }) => {
|
|
|
|
|
const MultipleFeaturesPopup = ({ features, categories }) => {
|
|
|
|
|
const { setPopup } = usePopup();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
@ -65,6 +68,7 @@ const MultipleFeaturesPopup = ({ features }) => {
|
|
|
|
|
<div className="flex w-full">
|
|
|
|
|
<span className="truncate">
|
|
|
|
|
{feature.properties.name ?? feature.properties.category}
|
|
|
|
|
{feature.properties.category_id && categories.find(c => c.id === feature.properties.category_id).name}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
@ -87,12 +91,34 @@ const YandexPanoramaLink = ({ lat, lng }) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const MapPopup = ({ features, lat, lng, onClose }) => {
|
|
|
|
|
const { data: postamatesAndPvzGroups } = usePostamatesAndPvzGroups();
|
|
|
|
|
|
|
|
|
|
const filteredPostamatesCategories = useMemo(() => {
|
|
|
|
|
if (!postamatesAndPvzGroups) return [];
|
|
|
|
|
return postamatesAndPvzGroups
|
|
|
|
|
.filter((category) => category.visible)
|
|
|
|
|
.map((category) => {
|
|
|
|
|
return {
|
|
|
|
|
...category,
|
|
|
|
|
groups: [...category.groups.filter((group) => group.visible)],
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}, [postamatesAndPvzGroups]);
|
|
|
|
|
|
|
|
|
|
const postamatesGroups = useMemo(() => {
|
|
|
|
|
if (!filteredPostamatesCategories) return [];
|
|
|
|
|
return filteredPostamatesCategories
|
|
|
|
|
.map((category) => {
|
|
|
|
|
return [...category.groups.filter((group) => group.visible)]
|
|
|
|
|
}).flat();
|
|
|
|
|
}, [postamatesAndPvzGroups]);
|
|
|
|
|
|
|
|
|
|
const getContent = () => {
|
|
|
|
|
if (features.length === 1) {
|
|
|
|
|
return <SingleFeaturePopup feature={features[0]} />;
|
|
|
|
|
return <SingleFeaturePopup feature={features[0]} groups={postamatesGroups} categories={filteredPostamatesCategories} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <MultipleFeaturesPopup features={features} />;
|
|
|
|
|
return <MultipleFeaturesPopup features={features} categories={filteredPostamatesCategories} />;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|