Skip to content

Commit 94ac0b4

Browse files
authored
Merge pull request #83 from part3-4team-Taskify/sidemenuApi
[Feat] 사이드 메뉴 Api연결
2 parents f9904fa + 187e028 commit 94ac0b4

File tree

4 files changed

+68
-40
lines changed

4 files changed

+68
-40
lines changed

src/api/axiosInstance.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import axios from "axios";
22

3+
// 👉 디버깅용 로그 출력
4+
console.log("🔐 BASE_URL:", process.env.NEXT_PUBLIC_BASE_URL);
5+
console.log("🔐 API_TOKEN:", process.env.NEXT_PUBLIC_API_TOKEN);
6+
37
const axiosInstance = axios.create({
48
baseURL: process.env.NEXT_PUBLIC_BASE_URL,
59
});
610

11+
// 👉 Authorization 헤더 자동 설정
712
axiosInstance.defaults.headers.common["Authorization"] =
8-
`Bearer ${process.env.NEXT_PUBLIC_API_TOKEN} `;
13+
`Bearer ${process.env.NEXT_PUBLIC_API_TOKEN}`;
914

1015
export default axiosInstance;

src/api/sidemenu.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import axiosInstance from "./axiosInstance";
2+
3+
export interface Dashboard {
4+
id: number;
5+
title: string;
6+
color: string;
7+
userId: number;
8+
createdAt: string;
9+
updatedAt: string;
10+
createdByMe: boolean;
11+
}
12+
13+
export const getDashboards = async ({
14+
teamId,
15+
navigationMethod = "pagination",
16+
page = 1,
17+
size = 10,
18+
}: {
19+
teamId: string;
20+
navigationMethod?: "pagination";
21+
page?: number;
22+
size?: number;
23+
}): Promise<{
24+
dashboards: Dashboard[];
25+
totalCount: number;
26+
cursorId: string | null;
27+
}> => {
28+
const res = await axiosInstance.get(`${teamId}/dashboards`, {
29+
params: { navigationMethod, page, size },
30+
});
31+
32+
return res.data;
33+
};

src/components/SideMenu/SideMenu.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,45 @@ import clsx from "clsx";
22
import Image from "next/image";
33
import Link from "next/link";
44
import { useRouter } from "next/router";
5+
import { useEffect, useState } from "react";
56

6-
import { Dashboard } from "@/components/SideMenu/dashboard";
7+
import { getDashboards } from "@/api/sidemenu";
78

8-
interface Props {
9-
dashboardList: Dashboard[];
9+
interface Dashboard {
10+
id: number;
11+
title: string;
12+
color: string;
13+
userId: number;
14+
createdAt: string;
15+
updatedAt: string;
16+
createdByMe: boolean;
1017
}
1118

12-
export default function SideMenu({ dashboardList }: Props) {
19+
interface SideMenuProps {
20+
teamId: string;
21+
}
22+
23+
export default function SideMenu({ teamId }: SideMenuProps) {
1324
const router = useRouter();
1425
const { boardid } = router.query;
1526
const boardId = parseInt(boardid as string);
1627

28+
const [dashboardList, setDashboardList] = useState<Dashboard[]>([]);
29+
30+
useEffect(() => {
31+
getDashboards({ teamId })
32+
.then((res) => setDashboardList(res.dashboards))
33+
.catch((err) => console.error("대시보드 로딩 실패:", err));
34+
}, [teamId]);
35+
1736
return (
18-
<aside
19-
className="h-screen overflow-y-auto border-r border-[var(--color-gray3)] px-3 py-5
20-
lg:w-[300px] md:w-[160px] sm:w-[67px] transition-all duration-200 flex flex-col"
21-
>
22-
{/* 🔥 로고 섹션 - 반응형 정렬 */}
37+
<aside className="h-screen overflow-y-auto border-r border-[var(--color-gray3)] px-3 py-5 lg:w-[300px] md:w-[160px] sm:w-[67px] transition-all duration-200 flex flex-col">
38+
{/* 로고 */}
2339
<div className="mb-14 px-3 sm:mb-9 sm:px-0">
2440
<Link
2541
href={"/"}
2642
className="flex lg:justify-start md:justify-start sm:justify-center"
2743
>
28-
{/* ✅ 태블릿 & 데스크톱: 큰 로고 (768px 이상) */}
2944
<Image
3045
src="/svgs/logo_taskify.svg"
3146
alt="Taskify Large Logo"
@@ -35,7 +50,6 @@ export default function SideMenu({ dashboardList }: Props) {
3550
priority
3651
unoptimized
3752
/>
38-
{/* ✅ 모바일 & 초소형 화면: 작은 로고 (767px 이하) */}
3953
<Image
4054
src="/svgs/logo.svg"
4155
alt="Taskify Small Logo"
@@ -48,10 +62,9 @@ export default function SideMenu({ dashboardList }: Props) {
4862
</Link>
4963
</div>
5064

51-
{/* 🔥 대시보드 리스트 타이틀 + 추가 버튼 */}
65+
{/* 대시보드 타이틀 */}
5266
<nav>
5367
<div className="mb-4 flex items-center justify-between px-3 md:px-2">
54-
{/* ✅ Dash Boards 텍스트 (768px 이상에서만 표시) */}
5568
<span className="hidden md:block font-12sb text-[var(--color-black)]">
5669
Dash Boards
5770
</span>
@@ -66,7 +79,7 @@ export default function SideMenu({ dashboardList }: Props) {
6679
</button>
6780
</div>
6881

69-
{/* 🔥 대시보드 목록 - 모바일에서 중앙 정렬 */}
82+
{/* 대시보드 목록 */}
7083
<ul className="flex flex-col lg:items-start md:items-start sm:items-center sm:w-full">
7184
{dashboardList.map((dashboard) => (
7285
<li
@@ -81,7 +94,6 @@ export default function SideMenu({ dashboardList }: Props) {
8194
href={`/dashboard/${dashboard.id}`}
8295
className="flex items-center gap-3 sm:gap-2"
8396
>
84-
{/* 컬러 아이콘 */}
8597
<svg
8698
xmlns="http://www.w3.org/2000/svg"
8799
width="8"
@@ -92,8 +104,6 @@ export default function SideMenu({ dashboardList }: Props) {
92104
>
93105
<circle cx="4" cy="4" r="4" />
94106
</svg>
95-
96-
{/* 대시보드 제목 & 크라운 아이콘 */}
97107
<div className="hidden md:flex items-center gap-2">
98108
<span className="truncate font-18m md:text-base">
99109
{dashboard.title}

src/pages/mydashboard.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,8 @@ import DashboardAddButton from "@/components/button/DashboardAddButton";
77
import CardButton from "@/components/button/CardButton";
88
import { PaginationBtn } from "@/components/button/PaginationBtn";
99

10-
const dummyDashboards: Dashboard[] = [
11-
{
12-
id: 1,
13-
title: "기획안",
14-
color: "#F87171",
15-
createdAt: "2024-01-01T00:00:00Z",
16-
updatedAt: "2024-01-02T00:00:00Z",
17-
createdByMe: true,
18-
userId: 101,
19-
},
20-
{
21-
id: 2,
22-
title: "디자인 시안",
23-
color: "#60A5FA",
24-
createdAt: "2024-01-03T00:00:00Z",
25-
updatedAt: "2024-01-04T00:00:00Z",
26-
createdByMe: false,
27-
userId: 102,
28-
},
29-
];
30-
3110
export default function MyDashboardPage() {
11+
const teamId = "13";
3212
const [dashCards, setDashCards] = useState<string[]>([]);
3313
const [currentPage, setCurrentPage] = useState(1);
3414
const itemsPerPage = 6;
@@ -57,7 +37,7 @@ export default function MyDashboardPage() {
5737

5838
return (
5939
<div className="flex h-screen overflow-hidden">
60-
<SideMenu dashboardList={dummyDashboards} />
40+
<SideMenu teamId="13-4" />
6141

6242
<div className="flex flex-col flex-1 overflow-hidden">
6343
<HeaderDashboard />

0 commit comments

Comments
 (0)