diff --git a/src/pages/feedback/index.page.tsx b/src/pages/feedback/index.page.tsx index b4f0b042..05d4c634 100644 --- a/src/pages/feedback/index.page.tsx +++ b/src/pages/feedback/index.page.tsx @@ -68,26 +68,33 @@ export default function FeedbackList() { const renderReceivedFeedbackCards = () => { const now = new Date(); - const feedbackList = []; - for (const year in feedbacksByYearAndMonth) { - for (const month in feedbacksByYearAndMonth[year]) { - const feedbacks = feedbacksByYearAndMonth[year][month]; - const feedbackItems = feedbacks.map((feedback: Feedback) => { - return ( - - ); - }); + const feedbackList: ReactElement[] = []; + + if (!feedbacksByYearAndMonth) return null; + + const reversedYears = Object.keys(feedbacksByYearAndMonth).sort((a, b) => Number(b) - Number(a)); + + reversedYears.forEach((year) => { + const reversedMonths = Object.keys(feedbacksByYearAndMonth[year]).sort((a, b) => Number(b) - Number(a)); + + reversedMonths.forEach((month) => { + const reversedFeedbacks = [...feedbacksByYearAndMonth[year][month]].sort( + (a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime(), + ); + const feedbackElements = reversedFeedbacks.map((feedback) => ( + + )); feedbackList.push(
{now.getFullYear() === Number(year) ? `${month}월` : `${year}년 ${month}월`} -
{feedbackItems}
+
{feedbackElements}
, ); - } - } + }); + }); return feedbackList; };