Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/controllers/edit_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) {
return
}

entry, err = utils.ConvertISOToTaskwarriorFormat(entry)
if err != nil {
http.Error(w, fmt.Sprintf("Invalid entry date format: %v", err), http.StatusBadRequest)
return
}

logStore := models.GetLogStore()
job := Job{
Name: "Edit Task",
Expand Down
38 changes: 15 additions & 23 deletions frontend/src/components/HomeComponents/Tasks/TaskDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ export const TaskDialog = ({
<TableCell>
{editState.isEditingEntryDate ? (
<div className="flex items-center gap-2">
<DatePicker
<DateTimePicker
date={
editState.editedEntryDate &&
editState.editedEntryDate !== ''
Expand All @@ -1131,13 +1131,10 @@ export const TaskDialog = ({
// Handle YYYY-MM-DD format
const dateStr =
editState.editedEntryDate.includes('T')
? editState.editedEntryDate.split(
'T'
)[0]
: editState.editedEntryDate;
const parsed = new Date(
dateStr + 'T00:00:00'
);
? editState.editedEntryDate
: editState.editedEntryDate +
'T00:00:00';
const parsed = new Date(dateStr);
return isNaN(parsed.getTime())
? undefined
: parsed;
Expand All @@ -1147,13 +1144,16 @@ export const TaskDialog = ({
})()
: undefined
}
onDateChange={(date) =>
onDateTimeChange={(date, hasTime) =>
onUpdateState({
editedEntryDate: date
? format(date, 'yyyy-MM-dd')
? hasTime
? date.toISOString()
: format(date, 'yyyy-MM-dd')
: '',
})
}
placeholder="Select entry date and time"
/>

<Button
Expand All @@ -1174,12 +1174,8 @@ export const TaskDialog = ({
aria-label="cancel"
onClick={() =>
onUpdateState({
editedEntryDate: task.entry || '',
isEditingEntryDate: false,
editedEntryDate: task.entry
? task.entry.includes('T')
? task.entry.split('T')[0]
: task.entry
: '',
})
}
>
Expand All @@ -1193,16 +1189,12 @@ export const TaskDialog = ({
variant="ghost"
size="icon"
aria-label="edit"
onClick={() =>
onClick={() => {
onUpdateState({
isEditingEntryDate: true,
editedEntryDate: task.entry
? task.entry.includes('T')
? task.entry.split('T')[0]
: task.entry
: '',
})
}
editedEntryDate: task.entry || '',
});
}}
>
<PencilIcon className="h-4 w-4 text-gray-500" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ describe('Tasks Component', () => {
['End', 'End:', 'Select end date and time'],
['Due', 'Due:', 'Select due date and time'],
['Start', 'Start:', 'Select start date and time'],
['Entry', 'Entry:', 'Pick a date'],
['Entry', 'Entry:', 'Select entry date and time'],
])('shows red when task %s date is edited', async (_, label, placeholder) => {
render(<Tasks {...mockProps} />);

Expand Down
Loading