You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import { Popup } from "react-map-gl" ;
import { Button , Col , Row } from "antd" ;
import { twMerge } from "tailwind-merge" ;
import { TYPE _MAPPER } from "../config" ;
import { usePointSelection } from "../stores/usePointSelection" ;
const pointConfig = [
{
field : "name" ,
} ,
{
field : "category" ,
name : "Тип" ,
formatter : ( value ) => TYPE _MAPPER [ value ] ,
} ,
{
name : "Востребованность, у .е ." ,
formatter : ( value ) => Math . round ( value ) ,
} ,
] ;
export const MapPopup = ( { feature , lat , lng , onClose } ) => {
const { include , selection , exclude } = usePointSelection ( ) ;
const isSelected = selection . included . has ( feature . properties . id ) ;
const handleSelect = ( ) =>
isSelected
? exclude ( feature . properties . id )
: include ( feature . properties . id ) ;
return (
< Popup
longitude = { lng }
latitude = { lat }
anchor = "bottom"
onClose = { onClose }
closeOnClick = { false }
>
< div >
{ Object . entries ( feature . properties ) . map ( ( [ key , value ] ) => {
return (
< Row className = { twMerge ( "p-1" ) } key = { key } >
< Col className = { "font-semibold" } span = { 15 } >
{ key }
< / C o l >
< Col span = { 9 } > { value } < / C o l >
< / R o w >
) ;
} ) }
< / d i v >
< Button type = "text" className = "mt-2 mx-auto" block onClick = { handleSelect } >
{ isSelected ? "Исключить из выборки" : "Добавить в выборку" }
< / B u t t o n >
< / P o p u p >
) ;
} ;