feat: enhance date handling in TaskBasicFields and date-utils
- Integrated `ensureDate` and `formatDateForDateTimeInput` in `TaskBasicFields` for improved due date management. - Updated `date-utils` functions to accept both `Date` and `string` types, ensuring robust date validation and parsing. - Added `ensureDate` utility to handle various date inputs, improving error handling and consistency across date-related functions.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { Input } from '@/components/ui/Input';
|
||||
import { TaskPriority, TaskStatus } from '@/lib/types';
|
||||
import { getAllStatuses, getAllPriorities } from '@/lib/status-config';
|
||||
import { ensureDate, formatDateForDateTimeInput } from '@/lib/date-utils';
|
||||
|
||||
interface TaskBasicFieldsProps {
|
||||
title: string;
|
||||
@@ -109,7 +110,10 @@ export function TaskBasicFields({
|
||||
<Input
|
||||
label="Date d'échéance"
|
||||
type="datetime-local"
|
||||
value={dueDate ? new Date(dueDate.getTime() - dueDate.getTimezoneOffset() * 60000).toISOString().slice(0, 16) : ''}
|
||||
value={(() => {
|
||||
const date = ensureDate(dueDate);
|
||||
return date ? formatDateForDateTimeInput(date) : '';
|
||||
})()}
|
||||
onChange={(e) => onDueDateChange(e.target.value ? new Date(e.target.value) : undefined)}
|
||||
disabled={loading}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user