import { Modal, Button } from 'react-bootstrap' import { MapContainer, Marker, Popup, TileLayer } from 'react-leaflet' import { CSSProperties, useState } from 'react' import { LatLng } from 'leaflet' import LineDot from './LineDot' import { categoryNames } from '../assets/category' import { useBook, useRemoveAnnouncement } from '../hooks/api' import { Announcement } from '../api/announcement/types' import { iconItem } from '../utils/markerIcons' import { useId } from '../hooks' import SelectDisposalTrashbox from './SelectDisposalTrashbox' import StarRating from './StarRating' const styles = { container: { display: 'flex', alignItems: 'center', justifyContent: 'center', } as CSSProperties, map: { width: '100%', minHeight: 300, } as CSSProperties, } type ViewProps = { myId: number, announcement: Announcement, } const View = ({ myId, announcement: { name, category, bestBy, description, lat, lng, address, metro, userId }, }: ViewProps) => ( <>

{name}

{categoryNames[category]} {/* dot */} Годен до {new Date(bestBy).toLocaleString('ru-RU')}

{description}

Рейтинг пользователя:

{address}
{metro}
) type ControlProps = { myId: number, closeRefresh: () => void, announcement: Announcement, showDispose: () => void } function Control({ myId, closeRefresh, announcement: { bookedBy, id, userId }, showDispose, }: ControlProps) { const { handleBook, bookButton } = useBook() const { handleRemove, removeButton } = useRemoveAnnouncement(closeRefresh) return ( <>

Забронировали {bookedBy + (bookButton.disabled ? 1 : 0)} чел.

{(myId === userId) ? ( <>