Skip to content

Commit 903a08f

Browse files
committed
feat: 관리자 페이지 롤링 페이퍼 설정 화면에 페이지네이션 적용
1 parent c96daf0 commit 903a08f

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

src/apis/rolling.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,19 @@ export const postNewRollingPaper = async (title: string) => {
5757
}
5858
};
5959

60-
export const getRollingPaperList = async (): Promise<RollingPaperList> => {
60+
export const getRollingPaperList = async (
61+
page: string | number,
62+
size: number,
63+
): Promise<RollingPaperList> => {
6164
try {
6265
const {
6366
data: { data },
64-
} = await client.get('/api/admin/event-posts');
67+
} = await client.get('/api/admin/event-posts', {
68+
params: {
69+
page,
70+
size,
71+
},
72+
});
6573
return data;
6674
} catch (error) {
6775
console.error(error);

src/pages/Admin/RollingPaper.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ import PageTitle from './components/AdminPageTitle';
99
import RollingPaperItem from './components/RollingPaperItem';
1010
import WrapperFrame from './components/WrapperFrame';
1111
import WrapperTitle from './components/WrapperTitle';
12+
import PagenationNavigation from './components/PagenationNavigation';
13+
14+
const SIZE = 10;
1215

1316
export default function AdminRollingPaper() {
1417
const [activeModal, setActiveModal] = useState(false);
15-
const { data, isLoading, isSuccess } = useQuery({
16-
queryKey: ['admin-rolling-paper'],
17-
queryFn: getRollingPaperList,
18+
const [currentPage, setCurrentPage] = useState<string>('1');
19+
const { data, isLoading, isSuccess, refetch } = useQuery({
20+
queryKey: ['admin-rolling-paper', currentPage],
21+
queryFn: () => getRollingPaperList(currentPage ?? 1, SIZE),
1822
});
1923

24+
const handleNowPage = (page: string) => {
25+
setCurrentPage(page);
26+
refetch();
27+
};
28+
2029
return (
2130
<>
2231
{activeModal && <AddRollingPaperModal onClose={() => setActiveModal(false)} />}
@@ -58,7 +67,11 @@ export default function AdminRollingPaper() {
5867
)}
5968
</>
6069
)}
61-
{/* TODO: 페이지네이션 적용 */}
70+
<PagenationNavigation
71+
totalPage={Number(data?.totalPages)}
72+
buttonLength={5}
73+
handlePageNumberButtonClick={handleNowPage}
74+
/>
6275
</WrapperFrame>
6376
</>
6477
);

src/pages/Admin/components/PagenationNavigation.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ export default function PagenationNavigation({
5050
}
5151
};
5252

53-
const buttonStyle = 'border bg-white px-2 py-1 disabled:bg-gray-20';
53+
const buttonStyle = 'rounded-full bg-white w-8 h-8 disabled:bg-gray-20';
5454

5555
return (
5656
<div className="mt-5 flex h-10 w-full items-center justify-center">
57-
<div className="flex items-center">
57+
<div className="flex items-center gap-2">
5858
<button
59-
className={twMerge(buttonStyle)}
59+
className={twMerge(buttonStyle, 'w-14')}
6060
disabled={nowSection <= 0}
6161
onClick={() => {
6262
handlePrevButtonClick();
@@ -69,7 +69,7 @@ export default function PagenationNavigation({
6969
return (
7070
<button
7171
key={num}
72-
className={twMerge(buttonStyle, nowPageNumberAt === num && 'bg-accent-3')}
72+
className={twMerge(buttonStyle, nowPageNumberAt === num && 'bg-primary-2/50')}
7373
onClick={() => {
7474
handlePageButtonClick(num);
7575
}}
@@ -79,7 +79,7 @@ export default function PagenationNavigation({
7979
);
8080
})}
8181
<button
82-
className={twMerge(buttonStyle)}
82+
className={twMerge(buttonStyle, 'w-14')}
8383
disabled={nowSection >= totalSection}
8484
onClick={() => {
8585
handleNextButtonClick();

0 commit comments

Comments
 (0)