Skip to content

Commit b63f248

Browse files
feat(AddTaskDialog): add DateTimePicker for entry field (#383)
- Replace DatePicker with DateTimePicker for entry field in AddTaskDialog - Add entry to dateTimeFields array in tests - Support both date-only and datetime formats for entry Contributes: #325
1 parent bbfa2b1 commit b63f248

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

backend/utils/tw/add_task.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ func AddTaskToTaskwarrior(req models.AddTaskRequestBody, dueDate string) error {
5151
cmdArgs = append(cmdArgs, "depends:"+dependsStr)
5252
}
5353
if req.EntryDate != "" {
54-
cmdArgs = append(cmdArgs, "entry:"+req.EntryDate)
54+
entry, err := utils.ConvertISOToTaskwarriorFormat(req.EntryDate)
55+
if err != nil {
56+
return fmt.Errorf("unexpected date format error: %v", err)
57+
}
58+
cmdArgs = append(cmdArgs, "entry:"+entry)
5559
}
5660
if req.WaitDate != "" {
5761
wait, err := utils.ConvertISOToTaskwarriorFormat(req.WaitDate)

frontend/src/components/HomeComponents/Tasks/AddTaskDialog.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,27 @@ export const AddTaskdialog = ({
334334
Entry
335335
</Label>
336336
<div className="col-span-3">
337-
<DatePicker
338-
date={newTask.entry ? new Date(newTask.entry) : undefined}
339-
onDateChange={(date) => {
337+
<DateTimePicker
338+
date={
339+
newTask.entry
340+
? new Date(
341+
newTask.entry.includes('T')
342+
? newTask.entry
343+
: `${newTask.entry}T00:00:00`
344+
)
345+
: undefined
346+
}
347+
onDateTimeChange={(date, hasTime) => {
340348
setNewTask({
341349
...newTask,
342-
entry: date ? format(date, 'yyyy-MM-dd') : '',
350+
entry: date
351+
? hasTime
352+
? date.toISOString()
353+
: format(date, 'yyyy-MM-dd')
354+
: '',
343355
});
344356
}}
345-
placeholder="Select an entry date"
357+
placeholder="Select entry date and time"
346358
/>
347359
</div>
348360
</div>

frontend/src/components/HomeComponents/Tasks/__tests__/AddTaskDialog.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ describe('AddTaskDialog Component', () => {
406406
label: 'Wait',
407407
placeholder: 'Select wait date and time',
408408
},
409+
{
410+
name: 'entry',
411+
label: 'Entry',
412+
placeholder: 'Select entry date and time',
413+
},
409414
];
410415

411416
test.each(dateTimeFields)(
@@ -511,7 +516,6 @@ describe('AddTaskDialog Component', () => {
511516
describe('DatePicker fields', () => {
512517
const dateOnlyFields = [
513518
{ name: 'end', label: 'End', placeholder: 'Select an end date' },
514-
{ name: 'entry', label: 'Entry', placeholder: 'Select an entry date' },
515519
];
516520

517521
test.each(dateOnlyFields)(

0 commit comments

Comments
 (0)