@@ -4,13 +4,15 @@ import { useEffect, useState } from "react";
44import { fetchDashboardList } from "@/lib/apis/dashboardsApi" ;
55import { DashboardList } from "@/lib/types" ;
66import Pagination from "@/components/common/pagination-button/PaginationButton" ;
7+ import AddDashboardButton from "./AddDashboardButton" ;
8+ import DashboardCard from "./DashboardCard" ;
79
8- const PAGE_SIZE = 6 ;
10+ const PAGE_SIZE = 5 ;
911
1012export default function DashboardListSection ( { token } : { token : string } ) {
1113 const [ myDashboards , setMyDashboards ] = useState < DashboardList [ ] > ( [ ] ) ;
1214 const [ page , setPage ] = useState ( 1 ) ;
13- const [ totalPages , setTotalPages ] = useState ( 1 ) ;
15+ const [ totalPages , setTotalPages ] = useState ( 0 ) ;
1416 const [ loading , setLoading ] = useState ( false ) ;
1517
1618 useEffect ( ( ) => {
@@ -19,16 +21,16 @@ export default function DashboardListSection({ token }: { token: string }) {
1921 try {
2022 const {
2123 dashboards,
22- total ,
23- } : { dashboards : DashboardList [ ] ; total : number } =
24+ totalCount ,
25+ } : { dashboards : DashboardList [ ] ; totalCount : number } =
2426 await fetchDashboardList ( {
2527 token,
2628 page,
2729 size : PAGE_SIZE ,
2830 } ) ;
2931
3032 setMyDashboards ( dashboards . filter ( ( d ) => d . createdByMe ) ) ;
31- setTotalPages ( Math . ceil ( total / PAGE_SIZE ) ) ;
33+ setTotalPages ( Math . floor ( totalCount / 6 ) ) ;
3234 } catch ( error ) {
3335 console . error ( "대시보드를 불러오는 중 오류 발생:" , error ) ;
3436 } finally {
@@ -39,36 +41,30 @@ export default function DashboardListSection({ token }: { token: string }) {
3941 } , [ page , token ] ) ;
4042
4143 return (
42- < div className = "max-w-[1022px]" >
43- < button className = "px-4 py-2 bg-blue-500 text-white rounded-lg flex items-center" >
44- 새로운 대시보드 +
45- </ button >
46-
47- < div >
48- < h2 className = "text-lg font-semibold" > 내 대시보드</ h2 >
49- { myDashboards . length > 0 ? (
50- < ul className = "mt-4 space-y-2" >
51- { myDashboards . map ( ( dashboard ) => (
52- < li key = { dashboard . id } className = "p-4 bg-white shadow rounded-lg" >
53- { dashboard . title }
54- </ li >
55- ) ) }
56- </ ul >
57- ) : (
58- ! loading && (
59- < div className = "p-6 bg-gray-100 text-center rounded-lg" >
60- < p className = "text-gray-500" > 아직 생성한 대시보드가 없어요.</ p >
61- </ div >
62- )
63- ) }
44+ < div className = "flex flex-col max-w-[1022px] gap-4 pc:gap-3" >
45+ < div className = "grid grid-cols-1 gap-2 items-stretch tablet:grid-cols-2 tablet:gap-[10px] pc:grid-cols-3 pc:gap-3" >
46+ < AddDashboardButton />
47+ { myDashboards . map ( ( dashboard ) => (
48+ < DashboardCard
49+ key = { dashboard . id }
50+ id = { dashboard . id }
51+ title = { dashboard . title }
52+ color = { dashboard . color }
53+ createdByMe = { dashboard . createdByMe }
54+ />
55+ ) ) }
6456
6557 { loading && (
6658 < div className = "flex justify-center mt-4" >
67- < div className = "w-6 h-6 border-4 border-blue -500 border-t-transparent rounded-full animate-spin" > </ div >
59+ < div className = "w-6 h-6 border-4 border-gray -500 border-t-transparent rounded-full animate-spin" > </ div >
6860 </ div >
6961 ) }
70-
71- < div className = "flex justify-center mt-4" >
62+ </ div >
63+ < div className = "flex justify-end" >
64+ < div className = "flex items-center gap-3 tablet:gap-4" >
65+ < p className = "font-normal text-xs text-gray-800 tablet:text-md" >
66+ { totalPages } 페이지 중 { page }
67+ </ p >
7268 < Pagination
7369 currentPage = { page }
7470 totalPages = { totalPages }
0 commit comments