Skip to content

Commit e16817b

Browse files
committed
fix: 🐛 added toast for empty task name
1 parent ee1d301 commit e16817b

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

src/Agenda3/components/modals/TaskModal/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ const TaskModal = ({
325325
trigger={['click']}
326326
arrow={false}
327327
placement="bottomLeft"
328+
onOpenChange={(open) => {
329+
if (open && formData.startDateVal === undefined) {
330+
updateFormData({ startDateVal: dayjs() })
331+
}
332+
}}
328333
content={
329334
<div className="w-[300px] p-2">
330335
<Calendar
@@ -434,6 +439,11 @@ const TaskModal = ({
434439
trigger={['click']}
435440
arrow={false}
436441
placement="bottomLeft"
442+
onOpenChange={(open) => {
443+
if (open && formData.deadlineDateVal === undefined) {
444+
updateFormData({ deadlineDateVal: dayjs().add(1, 'day') })
445+
}
446+
}}
437447
content={
438448
<div className="w-[300px] p-2">
439449
<Calendar

src/Agenda3/components/modals/TaskModal/useCreate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ const useCreate = (initialData: Partial<CreateTaskForm> | null, messageApi: Mess
6060
if (!start && !deadline) {
6161
return messageApi.error(t('Pleasse specify start or deadline'))
6262
}
63+
if (formData.title?.trim()?.length === 0) {
64+
return messageApi.error(t('Title cannot be empty'))
65+
}
6366
return addNewEntity({
6467
type: 'task',
6568
data: {

src/Agenda3/components/modals/TaskModal/useEdit.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ const useEdit = (initialTask: AgendaTaskWithStartOrDeadline | null, messageApi:
9595
messageApi.error(message)
9696
throw new Error(message)
9797
}
98+
if (formData.title?.trim()?.length === 0) {
99+
const message = t('Title cannot be empty')
100+
messageApi.error(message)
101+
throw new Error(message)
102+
}
98103
const result = safeParse(EditFormSchema, formData)
99104
if (!result.success || !initialTask) {
100105
messageApi.error('Failed to edit task block')

src/Agenda3/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@
4747
"tomorrow": "tomorrow",
4848
"week": "week",
4949
"month": "month",
50-
"Exit": "Exit"
50+
"Exit": "Exit",
51+
"Title cannot be empty": "Title cannot be empty",
52+
"Pleasse specify start or deadline": "Pleasse specify start or deadline"
5153
}

src/Agenda3/locales/zh-CN/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@
4747
"tomorrow": "明天",
4848
"week": "本周",
4949
"month": "本月",
50-
"Exit": "退出"
50+
"Exit": "退出",
51+
"Title cannot be empty": "标题不能为空",
52+
"Pleasse specify start or deadline": "请指定开始或截止日期"
5153
}

0 commit comments

Comments
 (0)