Skip to content

Commit

Permalink
feat: 히스토리 최신 순으로 정렬
Browse files Browse the repository at this point in the history
  • Loading branch information
gogumalatte committed Dec 6, 2024
1 parent 8d583d8 commit 32eed0e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages/MainPage/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ export const Sidebar: React.FC<SidebarProps> = ({ isOpen, toggleSidebar }) => {
});
if (response.ok) {
const data: History[] = await response.json();
setHistories(data);
// Sort histories by date in descending order (most recent first)
const sortedHistories = data.sort(
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
);
setHistories(sortedHistories);
} else {
console.error("히스토리 불러오기에 실패했습니다.");
}
Expand Down

0 comments on commit 32eed0e

Please sign in to comment.