diff --git a/front/src/api/removeAnnouncement/index.ts b/front/src/api/removeAnnouncement/index.ts new file mode 100644 index 0000000..fa88c16 --- /dev/null +++ b/front/src/api/removeAnnouncement/index.ts @@ -0,0 +1,12 @@ +import { API_URL } from '../../config' +import { RemoveAnnouncement, RemoveAnnouncementResponse } from './types' + +const composeRemoveAnnouncementURL = () => ( + API_URL + '/announcement?' +) + +const processRemoveAnnouncement = (data: RemoveAnnouncementResponse): RemoveAnnouncement => { + return data.Answer +} + +export { composeRemoveAnnouncementURL, processRemoveAnnouncement } diff --git a/front/src/api/removeAnnouncement/types.ts b/front/src/api/removeAnnouncement/types.ts new file mode 100644 index 0000000..0c5bb2b --- /dev/null +++ b/front/src/api/removeAnnouncement/types.ts @@ -0,0 +1,17 @@ +import { isObject } from '../../utils/types' + +type RemoveAnnouncementResponse = { + Answer: boolean +} + +const isRemoveAnnouncementResponse = (obj: unknown): obj is RemoveAnnouncementResponse => ( + isObject(obj, { + 'Answer': 'boolean' + }) +) + +type RemoveAnnouncement = boolean + +export type { RemoveAnnouncementResponse, RemoveAnnouncement } + +export { isRemoveAnnouncementResponse } diff --git a/front/src/components/AnnouncementDetails.tsx b/front/src/components/AnnouncementDetails.tsx index b604909..4a20086 100644 --- a/front/src/components/AnnouncementDetails.tsx +++ b/front/src/components/AnnouncementDetails.tsx @@ -3,10 +3,11 @@ import { MapContainer, Marker, Popup, TileLayer } from 'react-leaflet' import LineDot from './LineDot' import { categoryNames } from '../assets/category' -import { useBook } from '../hooks/api' +import { useBook, useRemoveAnnouncement } from '../hooks/api' import { Announcement } from '../api/announcement/types' import { iconItem } from '../utils/markerIcons' import { CSSProperties } from 'react' +import { useId } from '../hooks' type AnnouncementDetailsProps = { close: () => void, @@ -19,12 +20,19 @@ const styles = { alignItems: 'center', justifyContent: 'center', } as CSSProperties, + map: { + width: '100%', + minHeight: 300, + } as CSSProperties, } function AnnouncementDetails({ close, announcement: { - id, name, category, bestBy, description, lat, lng, address, metro + id, name, category, bestBy, description, lat, lng, address, metro, bookedBy, userId } }: AnnouncementDetailsProps) { const { handleBook, bookButton } = useBook() + const { handleRemove, removeButton } = useRemoveAnnouncement(close) + + const myId = useId() return (