diff --git a/src/app/(after-login)/mydashboard/_components/DashboardListSection.tsx b/src/app/(after-login)/mydashboard/_components/DashboardListSection.tsx new file mode 100644 index 0000000..9117484 --- /dev/null +++ b/src/app/(after-login)/mydashboard/_components/DashboardListSection.tsx @@ -0,0 +1,65 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { fetchDashboardList } from "@/lib/apis/dashboardsApi"; +import { DashboardList } from "@/lib/types"; + +const PAGE_SIZE = 6; + +export default function DashboardListSection({ token }: { token: string }) { + const [myDashboards, setMyDashboards] = useState([]); + const [page, setPage] = useState(1); + + setPage(1); // vercel 배포 때문에 임시로 넣은 코드라 삭제하시면 됩니다. + + const [loading, setLoading] = useState(true); + + useEffect(() => { + async function loadDashboards() { + try { + const { dashboards }: { dashboards: DashboardList[] } = + await fetchDashboardList({ + token: token, + page: page, + size: PAGE_SIZE, + }); + + setMyDashboards( + dashboards.filter((dashboard) => dashboard.createdByMe) + ); + } catch (error) { + console.error("대시보드를 불러오는 중 오류 발생:", error); + } finally { + setLoading(false); + } + } + loadDashboards(); + }, []); + + return ( + <> + + +
+

내 대시보드

+ {loading ? ( +

로딩 중...

+ ) : myDashboards.length > 0 ? ( + + ) : ( +
+

아직 생성한 대시보드가 없어요.

+
+ )} +
+ + ); +} diff --git a/src/app/(after-login)/mydashboard/_components/InvitationSection.tsx b/src/app/(after-login)/mydashboard/_components/InvitationSection.tsx new file mode 100644 index 0000000..69824d9 --- /dev/null +++ b/src/app/(after-login)/mydashboard/_components/InvitationSection.tsx @@ -0,0 +1,17 @@ +export default function InvitationSection({ token }: { token: string }) { + return ( +
+
+
+

+ 초대받은 대시보드 +

+

{token}

+
+
+
+
+
+
+ ); +} diff --git a/src/app/(after-login)/mydashboard/page.tsx b/src/app/(after-login)/mydashboard/page.tsx index 701eee4..23066a6 100644 --- a/src/app/(after-login)/mydashboard/page.tsx +++ b/src/app/(after-login)/mydashboard/page.tsx @@ -1,3 +1,14 @@ +import { cookies } from "next/headers"; +import DashboardListSection from "./_components/DashboardListSection"; +import InvitationSection from "./_components/InvitationSection"; + export default function Page() { - return
/mydashboard
; + const accessToken = cookies().get("accessToken")?.value ?? ""; + + return ( +
+ + +
+ ); }