diff --git a/src/containers/mydashboard/DashboardList/index.tsx b/src/containers/mydashboard/DashboardList/index.tsx index 8da103c2..6a118ad4 100644 --- a/src/containers/mydashboard/DashboardList/index.tsx +++ b/src/containers/mydashboard/DashboardList/index.tsx @@ -2,10 +2,6 @@ import Image from 'next/image'; import Link from 'next/link'; import { useState } from 'react'; -import arrowBlack from '@/../public/icons/arrow-black.svg'; -import arrowWhite from '@/../public/icons/arrow-white.svg'; -import crown from '@/../public/icons/crown.svg'; -import plus from '@/../public/icons/plus-filled.svg'; import useFetchData from '@/hooks/useFetchData'; import { getDashboardsList } from '@/services/getService'; import { DashboardsResponse } from '@/types/Dashboard.interface'; @@ -17,6 +13,8 @@ export default function DashboardList() { getDashboardsList('pagination', currentChunk, 5), ); + const totalPage = dashboardResponse ? Math.max(1, Math.ceil(dashboardResponse.totalCount / 5)) : 1; + if (error) { return (
@@ -29,10 +27,9 @@ export default function DashboardList() { const handleNext = () => { const nextChunk = currentChunk + 1; - if (dashboardResponse && nextChunk <= Math.ceil(dashboardResponse.totalCount / 5)) { + if (nextChunk <= totalPage) { setCurrentChunk((prev) => prev + 1); } - console.log('nextChunk', nextChunk); }; const handlePrev = () => { @@ -41,7 +38,6 @@ export default function DashboardList() { if (prevChunk >= 1) { setCurrentChunk((prev) => prev - 1); } - console.log('prevChunk', prevChunk); }; return ( @@ -50,7 +46,7 @@ export default function DashboardList() {
  • {dashboardResponse?.dashboards.map((dashboard) => ( @@ -59,9 +55,9 @@ export default function DashboardList() {

    {dashboard.title}

    - {dashboard.createdByMe && my} + {dashboard.createdByMe && my}
    - arrow + arrow ))} @@ -69,11 +65,11 @@ export default function DashboardList() {
    - {dashboardResponse ? Math.ceil(dashboardResponse.totalCount / 5) : 1} 페이지 중 {currentChunk} + {totalPage} 페이지 중 {currentChunk} - - + +
    ); @@ -82,13 +78,21 @@ export default function DashboardList() { interface NavButtonProps { direction: 'left' | 'right'; onClick: () => void; + isDisable?: boolean; } -const NavButton = ({ direction, onClick }: NavButtonProps) => ( +const NavButton = ({ direction, onClick, isDisable }: NavButtonProps) => ( );