Skip to content

branch: 공지사항페이지 api 연동#61

Merged
cryingdryice merged 7 commits intodevelopfrom
feature/announce_list
Nov 11, 2025
Merged

branch: 공지사항페이지 api 연동#61
cryingdryice merged 7 commits intodevelopfrom
feature/announce_list

Conversation

@cryingdryice
Copy link
Contributor

구현 내용

  • 공지사항 목록 api 연동
  • 공지사항 조회 api 연동
image

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Visit the preview URL for this PR (updated for commit 68b2d02):

https://web-deploy-9d41a--pr61-feature-announce-lis-yn0fkrtq.web.app

(expires Tue, 18 Nov 2025 09:55:27 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4a5d43964536093bf8932015bdd49b24c5b660ce

Copy link
Member

@whitecity01 whitecity01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 데이터를 추가해 보고 테스팅 해본 결과 두 번째 페이지에서 detail 접속 후 x 버튼을 누르면 1페이지로 이동하고 있습니다. 확인 부탁드립니다.

Comment on lines 4 to 17
return (
<div className="announce-sort">
<button
className={sortOrder === "old" ? "active" : ""}
onClick={() => onChange("old")}
className={sortOrder === "DATE_ASC" ? "active" : ""}
onClick={() => onChange("DATE_ASC")}
>
오래된 순
</button>
<button
className={sortOrder === "new" ? "active" : ""}
onClick={() => onChange("new")}
className={sortOrder === "DATE_DESC" ? "active" : ""}
onClick={() => onChange("DATE_DESC")}
>
최신 순
</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최신/오래된 순 정렬 버튼은 재사용성 있는 컴포넌트 같은데 common 컴포넌트로 분리하는 건 어떨까요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 분리하는 편이 좋아보입니다

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분리해두었습니다~

Comment on lines 33 to 61
if (loading) {
return (
<div className="announce-detail-page-container">
<h1 className="announce-detail-title">공지사항</h1>
<div className="announce-detail-loading">로딩 중...</div>
</div>
);
}

const closeDetailpage = () => {
naviate(-1);
};
if (error) {
return (
<div className="announce-detail-page-container">
<h1 className="announce-detail-title">공지사항</h1>
<div className="announce-detail-error">{error}</div>
</div>
);
}

if (!notice) {
return (
<div className="announce-detail-page-container">
<h1 className="announce-detail-title">공지사항</h1>
<div className="announce-detail-empty">
공지사항을 찾을 수 없습니다.
</div>
</div>
);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반복되는 코드가 많아보이는데 함수화나 컴포넌트로 분리 해보는건 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 간소화해두었습니다!

className="announce-item"
>
notices.map((notice) => (
<div key={notice.notificationId} className="announce-item">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 정수 값으로 key 를 설정하고 있는 것으로 보입니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다~

Comment on lines 27 to 57
/** ✅ 공지사항 API 호출 */
const fetchNotices = async (page = 1, sort = sortOrder) => {
try {
setLoading(true);
setError(null);

const sortedNotices = [...filteredNotices].sort((a, b) => {
if (sortOrder === "new")
return new Date(b.createdAt) - new Date(a.createdAt);
return new Date(a.createdAt) - new Date(b.createdAt);
});
const res = await getAnnounceListAPI({
keyword: "",
page: page - 1, // 서버는 0부터 시작
sort,
});

const totalPages = Math.max(1, Math.ceil(sortedNotices.length / PAGE_SIZE));
const startIndex = (currentPage - 1) * PAGE_SIZE;
const currentItems = sortedNotices.slice(startIndex, startIndex + PAGE_SIZE);
console.log(res.page.totalPages);

// ✅ 응답 데이터 안전 처리
if (res?.content && res.content.length > 0) {
setNotices(res.content);
setTotalPages(res.page.totalPages);
} else {
setNotices([]);
setTotalPages(0); // ✅ 페이지가 없으면 0으로
}
} catch (err) {
setError("공지사항을 불러오는 중 오류가 발생했습니다.");
setTotalPages(0);
} finally {
setLoading(false);
}
};

/** ✅ 최초 로드 및 정렬/페이지 변경 시 다시 호출 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그 지피티 주석 냄새가 살짝 나는데 아니죠/??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅎㅎ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

@sernan96 sernan96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

더미데이터로 테스트해본 결과 공지사항의 페이지네이션이 동작을 하지 않고 있습니다. !!

@cryingdryice
Copy link
Contributor Author

현재 데이터를 추가해 보고 테스팅 해본 결과 두 번째 페이지에서 detail 접속 후 x 버튼을 누르면 1페이지로 이동하고 있습니다. 확인 부탁드립니다.

페이지,정렬 옵션이 url쿼리에 포함되지 않아 생긴 문제였습니다! 추가해두었습니다.

@cryingdryice cryingdryice merged commit f324446 into develop Nov 11, 2025
2 checks passed
@cryingdryice cryingdryice deleted the feature/announce_list branch November 18, 2025 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants