@@ -22,7 +22,7 @@ import { ArrowUpDown } from "lucide-react";
2222import { toast } from "sonner" ;
2323import KUGoodjob from "@/assets/KU_goodjob.png" ;
2424
25- type SortMethod = 'dday-asc' | 'dday-desc' | 'created' ;
25+ type SortMethod = 'dday-asc' | 'dday-desc' ;
2626
2727const SORT_METHOD_KEY = "todoSortMethod" ;
2828
@@ -48,7 +48,7 @@ const TodoList = () => {
4848 const [ customTodos , setCustomTodos ] = useState < TodoItemType [ ] > ( [ ] ) ;
4949 const [ showLoginModal , setShowLoginModal ] = useState ( false ) ;
5050 const [ error , setError ] = useState ( "" ) ;
51- const [ sortMethod , setSortMethod ] = useState < SortMethod > ( 'dday-asc ' ) ;
51+ const [ sortMethod , setSortMethod ] = useState < SortMethod > ( 'dday-desc ' ) ;
5252
5353 // 정렬 방식에 따라 전체 Todo 목록 정렬
5454 const allTodos : TodoItemType [ ] = useMemo ( ( ) => {
@@ -58,14 +58,9 @@ const TodoList = () => {
5858 if ( sortMethod === 'dday-asc' ) {
5959 // D-Day 오름차순: 가장 적게 남은 것부터
6060 return parseDDay ( a . dDay ) - parseDDay ( b . dDay ) ;
61- } else if ( sortMethod === 'dday-desc' ) {
61+ } else {
6262 // D-Day 내림차순: 가장 많이 남은 것부터
6363 return parseDDay ( b . dDay ) - parseDDay ( a . dDay ) ;
64- } else {
65- // 생성일순: createdAt 기준 (최신순)
66- const aCreated = a . type === 'custom' ? a . createdAt : 0 ;
67- const bCreated = b . type === 'custom' ? b . createdAt : 0 ;
68- return bCreated - aCreated ;
6964 }
7065 } ) ;
7166 } , [ ecampusTodos , customTodos , sortMethod ] ) ;
@@ -190,21 +185,10 @@ const TodoList = () => {
190185 // 정렬 방식 변경 및 저장
191186 const handleSortMethodChange = async ( ) => {
192187 const nextMethod : SortMethod =
193- sortMethod === 'dday-asc'
194- ? 'dday-desc'
195- : sortMethod === 'dday-desc'
196- ? 'created'
197- : 'dday-asc' ;
188+ sortMethod === 'dday-asc' ? 'dday-desc' : 'dday-asc' ;
198189
199190 setSortMethod ( nextMethod ) ;
200191 await setStorage ( { [ SORT_METHOD_KEY ] : nextMethod } ) ;
201-
202- const labels = {
203- 'dday-asc' : 'D-Day 오름차순' ,
204- 'dday-desc' : 'D-Day 내림차순' ,
205- 'created' : '생성일순' ,
206- } ;
207- toast . success ( `정렬: ${ labels [ nextMethod ] } ` ) ;
208192 } ;
209193
210194 // 사용자 정의 Todo 완료 상태 토글
@@ -281,7 +265,7 @@ const TodoList = () => {
281265 className = "gap-1.5"
282266 >
283267 < ArrowUpDown className = "h-4 w-4" />
284- Sort
268+ { sortMethod === 'dday-asc' ? '오름차순' : '내림차순' }
285269 </ Button >
286270 < TodoExportButton todoItems = { allTodos } />
287271 </ div >
0 commit comments