import * as React from 'react' import { Popup } from 'react-leaflet' import { Item, Tag } from '../../types' export interface MarkerPopupProps { item: Item, tags: Tag[] } const MarkerPopup = (props: MarkerPopupProps) => { const item: Item = props.item; const tags: Tag[] = props.tags; return ( {item.name} {item.start && item.end &&

{new Date(item.start).toISOString().substring(0, 10) || ""} - {new Date(item.end).toISOString().substring(0, 10) || ""}

}

{item.tags && tags.map((tag: Tag) => ( #{tag.name} )) }

) } export default MarkerPopup; function replaceURLs(message: string): string { if (!message) return ""; var urlRegex = /(^| )(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,10}(:[0-9]{1,10})?(\/.*)?$/gm; message = message.replace(urlRegex, function (url) { var hyperlink = url.replace(' ', ''); if (!hyperlink.match('^https?:\/\/')) { hyperlink = 'http://' + hyperlink; } return '' + url + '' }); var mailRegex = /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi; message = message.replace(mailRegex, function (mail) { return '' + mail + '' }); return message; }