Skip to content

Commit

Permalink
Fix: 여행일기 페이지네이션 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunJinNo committed Aug 24, 2024
1 parent 1c0d826 commit 0edc18d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/diary/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function getDiary(id: number) {
headers: {
Cookie: `${cookie?.name}=${cookie?.value}`,
},
next: { revalidate: 3600, tags: [`getDiary/${id}`] },
next: { revalidate: 60, tags: [`getDiary/${id}`] },
});

if (!response.ok) {
Expand Down
12 changes: 8 additions & 4 deletions src/components/diary/list/DiaryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function getDiaryList(page: number) {
headers: {
Cookie: `${cookie?.name}=${cookie?.value}`,
},
next: { revalidate: 3600, tags: ["getDiaryList"] },
next: { revalidate: 60, tags: ["getDiaryList"] },
},
);

Expand All @@ -31,6 +31,7 @@ interface Props {

const DiaryList = async ({ page }: Props) => {
const data = await getDiaryList(page - 1);
console.log(data);

return (
<div className="w-full">
Expand All @@ -46,12 +47,15 @@ const DiaryList = async ({ page }: Props) => {
</Link>
</div>
<div className="grid grid-cols-2 gap-5 max-[744px]:grid-cols-1">
{data.diaryContentResponse.length < 6 && <DiaryWriteButton />}
{data.diaryContentResponse.map((value, index) => (
{data.content.length < 6 && <DiaryWriteButton />}
{data.content.map((value, index) => (
<DiaryCardContainer key={index} diaryData={value} />
))}
</div>
<DiaryPaginationContainer currentPage={page} totalPages={10} />
<DiaryPaginationContainer
currentPage={page}
totalPages={data.totalPages}
/>
</div>
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/types/DiaryDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export interface GetDiaryResponseDto {
* 일기 목록 조회 응답 DTO
*/
export interface GetDiaryListResponseDto {
diaryContentResponse: {
totalPages: number;
totalElements: number;
size: number;
content: {
diaryId: number;
title: string;
titleImage: string;
Expand Down

0 comments on commit 0edc18d

Please sign in to comment.