Skip to content

Commit c8eadbf

Browse files
authored
Merge pull request #46 from Turtle-Hwan/feat/todo
Feat/todo
2 parents 0b4365a + f5e018d commit c8eadbf

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

src/components/Tabs/TodoList/TodoAddDialog.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ interface TodoAddDialogProps {
2121
const TodoAddDialog = ({ open, onOpenChange, onSuccess }: TodoAddDialogProps) => {
2222
const [title, setTitle] = useState("");
2323
const [subject, setSubject] = useState("");
24-
const [dueDate, setDueDate] = useState("");
25-
const [dueTime, setDueTime] = useState("");
24+
const [dueDate, setDueDate] = useState(new Date().toISOString().split('T')[0]);
25+
const [dueTime, setDueTime] = useState(new Date().toTimeString().slice(0, 5));
2626
const [isSubmitting, setIsSubmitting] = useState(false);
2727

2828
const handleSubmit = async (e: React.FormEvent) => {
@@ -60,8 +60,8 @@ const TodoAddDialog = ({ open, onOpenChange, onSuccess }: TodoAddDialogProps) =>
6060
// 폼 초기화
6161
setTitle("");
6262
setSubject("");
63-
setDueDate("");
64-
setDueTime("");
63+
setDueDate(new Date().toISOString().split('T')[0]);
64+
setDueTime(new Date().toTimeString().slice(0, 5));
6565

6666
// 다이얼로그 닫기
6767
onOpenChange(false);

src/components/Tabs/TodoList/TodoList.tsx

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ArrowUpDown } from "lucide-react";
2222
import { toast } from "sonner";
2323
import KUGoodjob from "@/assets/KU_goodjob.png";
2424

25-
type SortMethod = 'dday-asc' | 'dday-desc' | 'created';
25+
type SortMethod = 'dday-asc' | 'dday-desc';
2626

2727
const 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

Comments
 (0)