|
1 |
| -import React, { useEffect, useState } from "react"; |
| 1 | +import { bookmarkAPIs } from "@/apis/bookmark"; |
| 2 | +import { useCallback, useEffect, useState } from "react"; |
2 | 3 | import Map_detailOverlay from "../Map/Map_detailOverlay";
|
3 | 4 |
|
4 |
| -const events = [ |
5 |
| - { |
6 |
| - id: 1, |
7 |
| - imageURL: "/images/잠수교.png", |
8 |
| - title: "차 없는 잠수교 뚜벅뚜벅 축제", |
9 |
| - description: |
10 |
| - "2024 차 없는 잠수교 뚜벅뚜벅 축제의 오감으로 만나는 힐링 놀이터로 놀러와 힐링을 동시에 즐겨보세요.", |
11 |
| - startAt: new Date("2022-01-01T00:00:00"), |
12 |
| - finishAt: new Date("2022-01-01T01:00:00"), |
13 |
| - }, |
14 |
| - { |
15 |
| - id: 2, |
16 |
| - imageURL: "/images/잠수교.png", |
17 |
| - title: "차 없는 잠수교 뚜벅뚜벅 축제", |
18 |
| - description: |
19 |
| - "2024 차 없는 잠수교 뚜벅뚜벅 축제의 오감으로 만나는 힐링 놀이터로 놀러와 힐링을 동시에 즐겨보세요.", |
20 |
| - startAt: new Date("2022-01-02T00:00:00"), |
21 |
| - finishAt: new Date("2022-01-02T01:00:00"), |
22 |
| - }, |
23 |
| - { |
24 |
| - id: 3, |
25 |
| - imageURL: "/images/잠수교.png", |
26 |
| - title: "차 없는 잠수교 뚜벅뚜벅 축제", |
27 |
| - description: |
28 |
| - "2024 차 없는 잠수교 뚜벅뚜벅 축제의 오감으로 만나는 힐링 놀이터로 놀러와 힐링을 동시에 즐겨보세요.", |
29 |
| - startAt: new Date("2022-01-03T00:00:00"), |
30 |
| - finishAt: new Date("2022-01-03T01:00:00"), |
31 |
| - }, |
32 |
| - { |
33 |
| - id: 4, |
34 |
| - imageURL: "/images/잠수교.png", |
35 |
| - title: "차 없는 잠수교 뚜벅뚜벅 축제", |
36 |
| - description: |
37 |
| - "2024 차 없는 잠수교 뚜벅뚜벅 축제의 오감으로 만나는 힐링 놀이터로 놀러와 힐링을 동시에 즐겨보세요.", |
38 |
| - startAt: new Date("2022-01-04T00:00:00"), |
39 |
| - finishAt: new Date("2022-01-04T01:00:00"), |
40 |
| - }, |
41 |
| - // Add more events as needed |
42 |
| -]; |
43 |
| - |
44 | 5 | const List_otherEvent = () => {
|
| 6 | + const [data, setData] = useState<any>(); |
| 7 | + |
| 8 | + const getBookmarks = useCallback(async () => { |
| 9 | + const { data } = await bookmarkAPIs.getBookmarks(); |
| 10 | + setData(data.data); |
| 11 | + }, []); |
| 12 | + |
| 13 | + useEffect(() => { |
| 14 | + getBookmarks(); |
| 15 | + }, [getBookmarks]); |
| 16 | + |
| 17 | + const deleteBookmark = async (bookmarkId: number) => { |
| 18 | + await bookmarkAPIs.deleteBookmark(bookmarkId); |
| 19 | + const { data } = await bookmarkAPIs.getBookmarks(); |
| 20 | + setData(data.data); |
| 21 | + }; |
| 22 | + |
45 | 23 | return (
|
46 |
| - <div className="flex flex-col gap-[16px]"> |
47 |
| - {events.map((event) => ( |
48 |
| - <Map_detailOverlay |
49 |
| - key={event.id} |
50 |
| - title={event.title} |
51 |
| - description={event.description} |
52 |
| - startAt={event.startAt} |
53 |
| - finishAt={event.finishAt} |
54 |
| - imageURL={event.imageURL} |
55 |
| - /> |
| 24 | + <div className="flex flex-col gap-[16px] w-full"> |
| 25 | + {data?.map((event: any, index: number) => ( |
| 26 | + <div |
| 27 | + key={`${event.bookmarkId}-${index}`} |
| 28 | + className="flex w-full overflow-auto gap-[16px] scrollbar-hide" |
| 29 | + > |
| 30 | + <Map_detailOverlay |
| 31 | + title={event.title} |
| 32 | + description={event.description} |
| 33 | + startAt={event.startAt} |
| 34 | + finishAt={event.finishAt} |
| 35 | + imageURL={event.imageURL} |
| 36 | + /> |
| 37 | + <button |
| 38 | + className="bg-[#FF5757] rounded-full text-white flex items-center justify-center w-[50px] h-[50px] flex-shrink-0 self-center" |
| 39 | + onClick={() => deleteBookmark(event.bookmarkId)} |
| 40 | + > |
| 41 | + X |
| 42 | + </button> |
| 43 | + </div> |
56 | 44 | ))}
|
57 | 45 | </div>
|
58 | 46 | );
|
|
0 commit comments