Skip to content

Commit 94a6540

Browse files
committed
feat: Implemented my_page logic
1 parent 4818cdd commit 94a6540

File tree

9 files changed

+84
-58
lines changed

9 files changed

+84
-58
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"react-kakao-maps-sdk": "^1.1.26",
2121
"swiper": "^11.1.3",
2222
"swr": "^2.2.5",
23+
"tailwind-scrollbar-hide": "^1.1.7",
2324
"universal-cookie": "^7.1.4",
2425
"zustand": "^4.5.2"
2526
},

src/apis/bookmark.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import api from "./common";
2+
3+
export const bookmarkAPIs = {
4+
getBookmarks: async () => api.getWithAuth("bookmark"),
5+
6+
postBookmarks: async (id: number) =>
7+
api.postWithAuth("bookmark", { eventId: id }),
8+
9+
deleteBookmark: async (id: number) => api.delete(`bookmark/${id}`),
10+
};

src/apis/event.ts

+2
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ export const eventApis = {
2828
distance: number;
2929
}
3030
) => api.get(`event/${id}`, param),
31+
32+
getMyEvent: async () => api.getWithAuth(`event/my`),
3133
};

src/components/Map/Map_detailOverlay.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Map_detailOverlay: FC<Props> = ({
2222
const formattedFinishAt = dayjs(finishAt).format("YYYY.MM.DD");
2323

2424
return (
25-
<div className="w-full h-[132px] max-w-[480px] flex rounded-[16px] ">
25+
<div className="w-full h-[132px] max-w-[480px] flex rounded-[16px] shrink-0">
2626
<div className="min-w-[132px] min-h-[132px]">
2727
<Image
2828
width={132}

src/components/mypage/List_myEvent.tsx

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useEffect, useState } from "react";
1+
import { eventApis } from "@/apis/event";
2+
import { useCallback, useEffect, useState } from "react";
23
import Map_detailOverlay from "../Map/Map_detailOverlay";
34

45
const events = [
@@ -24,9 +25,24 @@ const events = [
2425
];
2526

2627
const List_myEvent = () => {
28+
const [myEvent, setMyEvent] = useState<any>();
29+
30+
const getMyEvent = useCallback(async () => {
31+
try {
32+
const { data } = await eventApis.getMyEvent();
33+
setMyEvent(data.data);
34+
} catch (error) {
35+
console.log(error);
36+
}
37+
}, []);
38+
39+
useEffect(() => {
40+
getMyEvent();
41+
}, [getMyEvent]);
42+
2743
return (
28-
<div className="flex flex-col gap-[16px]">
29-
{events.map((event) => (
44+
<div className="flex flex-col gap-[16px] w-full">
45+
{myEvent?.map((event: any) => (
3046
<Map_detailOverlay
3147
key={event.id}
3248
title={event.title}

src/components/mypage/List_otherEvent.tsx

+39-51
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,46 @@
1-
import React, { useEffect, useState } from "react";
1+
import { bookmarkAPIs } from "@/apis/bookmark";
2+
import { useCallback, useEffect, useState } from "react";
23
import Map_detailOverlay from "../Map/Map_detailOverlay";
34

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-
445
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+
4523
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>
5644
))}
5745
</div>
5846
);

src/pages/mypage/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const Mypage = () => {
1919

2020
const getUser = useCallback(async () => {
2121
try {
22-
const response = await memberApis.getMemberMe();
23-
setUserData(response.data.data);
22+
const { data } = await memberApis.getMemberMe();
23+
setUserData(data.data);
2424
} catch (error) {
2525
console.log(error);
2626
router.replace("/login");

tailwind.config.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ const config: Config = {
103103
},
104104
},
105105
extend: {},
106-
plugins: [require("@tailwindcss/line-clamp")],
106+
plugins: [
107+
require("@tailwindcss/line-clamp"),
108+
require("tailwind-scrollbar-hide"),
109+
],
107110
} satisfies Config;
108111

109112
export default config;

0 commit comments

Comments
 (0)