Add popup for other layers

dev
Platon Yasev 3 years ago
parent 13858588b8
commit 14641e13d7

@ -3,6 +3,8 @@ import { otherPostamatesLayer } from "./layers-config";
import { useLayersVisibility } from "../../stores/useLayersVisibility"; import { useLayersVisibility } from "../../stores/useLayersVisibility";
import { LAYER_IDS } from "./constants"; import { LAYER_IDS } from "./constants";
const typeFilter = ["==", ["get", "type"], "Постамат"];
export const OtherPostamates = () => { export const OtherPostamates = () => {
const { isVisible } = useLayersVisibility(); const { isVisible } = useLayersVisibility();
@ -16,6 +18,7 @@ export const OtherPostamates = () => {
layout={{ layout={{
visibility: isVisible[LAYER_IDS.other] ? "visible" : "none", visibility: isVisible[LAYER_IDS.other] ? "visible" : "none",
}} }}
filter={typeFilter}
/> />
</> </>
); );

@ -3,6 +3,8 @@ import { pvzPointLayer } from "./layers-config";
import { useLayersVisibility } from "../../stores/useLayersVisibility"; import { useLayersVisibility } from "../../stores/useLayersVisibility";
import { LAYER_IDS } from "./constants"; import { LAYER_IDS } from "./constants";
const typeFilter = ["==", ["get", "type"], "пвз"];
export const PVZ = () => { export const PVZ = () => {
const { isVisible } = useLayersVisibility(); const { isVisible } = useLayersVisibility();
@ -16,6 +18,7 @@ export const PVZ = () => {
layout={{ layout={{
visibility: isVisible[LAYER_IDS.pvz] ? "visible" : "none", visibility: isVisible[LAYER_IDS.pvz] ? "visible" : "none",
}} }}
filter={typeFilter}
/> />
</> </>
); );

@ -143,6 +143,7 @@ export const MapComponent = () => {
LAYER_IDS.filteredWorking, LAYER_IDS.filteredWorking,
LAYER_IDS.cancelled, LAYER_IDS.cancelled,
LAYER_IDS.pvz, LAYER_IDS.pvz,
LAYER_IDS.other,
]} ]}
onClick={handleClick} onClick={handleClick}
onMouseEnter={handleMouseEnter} onMouseEnter={handleMouseEnter}

@ -2,22 +2,31 @@ import { CATEGORIES, STATUSES } from "../../../config";
import { import {
popupConfig, popupConfig,
residentialPointConfig, residentialPointConfig,
rivalsConfig,
workingPointFields, workingPointFields,
} from "./config"; } from "./config";
import { Col, Row } from "antd"; import { Col, Row } from "antd";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
import { LAYER_IDS } from "../../Layers/constants";
export const FeatureProperties = ({ feature, dynamicStatus }) => { export const FeatureProperties = ({ feature, dynamicStatus }) => {
const isResidential = feature.properties.category === CATEGORIES.residential; const isResidential = feature.properties.category === CATEGORIES.residential;
const isWorking = feature.properties.status === STATUSES.working; const isWorking = feature.properties.status === STATUSES.working;
const isRivals =
feature.layer.id === LAYER_IDS.pvz || feature.layer.id === LAYER_IDS.other;
const config = isResidential ? residentialPointConfig : popupConfig; const getConfig = () => {
if (isRivals) {
return rivalsConfig;
}
const finalConfig = isWorking ? [...config, ...workingPointFields] : config; const config = isResidential ? residentialPointConfig : popupConfig;
return isWorking ? [...config, ...workingPointFields] : config;
};
return ( return (
<div> <div>
{finalConfig.map(({ field, name, render }) => { {getConfig().map(({ field, name, render }) => {
const value = const value =
dynamicStatus && field === "status" dynamicStatus && field === "status"
? dynamicStatus ? dynamicStatus

@ -93,3 +93,8 @@ export const workingPointFields = [
{ name: "Расхождение с прогнозом", field: "delta_current" }, { name: "Расхождение с прогнозом", field: "delta_current" },
{ name: "Зрелость", field: "age_day" }, { name: "Зрелость", field: "age_day" },
]; ];
export const rivalsConfig = [
{ name: "Инфо", field: "info" },
{ name: "Категория", field: "type" },
];

Loading…
Cancel
Save