feat: enhance checkbox update functionality

- Updated `handleUpdateCheckbox` to accept an optional `date` parameter for modifying date/time.
- Adjusted related components (`DailyCheckboxItem`, `DailySection`, `EditCheckboxModal`) to support the new date functionality, improving task management capabilities.
- Added date input field in `EditCheckboxModal` for user interaction with date/time settings.
This commit is contained in:
Julien Froidefond
2025-09-30 10:02:58 +02:00
parent df7d2a9afa
commit d1d65cdca1
4 changed files with 25 additions and 8 deletions

View File

@@ -103,12 +103,17 @@ export function DailyPageClient({
await refreshDailyDates();
};
const handleUpdateCheckbox = async (checkboxId: string, text: string, type: DailyCheckboxType, taskId?: string) => {
const handleUpdateCheckbox = async (checkboxId: string, text: string, type: DailyCheckboxType, taskId?: string, date?: Date) => {
await updateCheckbox(checkboxId, {
text,
type,
taskId // Permet la liaison tâche pour tous les types
taskId, // Permet la liaison tâche pour tous les types
date // Permet la modification de la date/heure
});
// Refresh dates après modification pour mettre à jour le calendrier si la date a changé
if (date) {
await refreshDailyDates();
}
};
const handleReorderCheckboxes = async (date: Date, checkboxIds: string[]) => {

View File

@@ -9,7 +9,7 @@ import { EditCheckboxModal } from './EditCheckboxModal';
interface DailyCheckboxItemProps {
checkbox: DailyCheckbox;
onToggle: (checkboxId: string) => Promise<void>;
onUpdate: (checkboxId: string, text: string, type: DailyCheckboxType, taskId?: string) => Promise<void>;
onUpdate: (checkboxId: string, text: string, type: DailyCheckboxType, taskId?: string, date?: Date) => Promise<void>;
onDelete: (checkboxId: string) => Promise<void>;
saving?: boolean;
}
@@ -93,8 +93,8 @@ export function DailyCheckboxItem({
setEditingCheckbox(checkbox);
};
const handleSaveAdvancedEdit = async (text: string, type: DailyCheckboxType, taskId?: string) => {
await onUpdate(checkbox.id, text, type, taskId);
const handleSaveAdvancedEdit = async (text: string, type: DailyCheckboxType, taskId?: string, date?: Date) => {
await onUpdate(checkbox.id, text, type, taskId, date);
setEditingCheckbox(null);
};

View File

@@ -17,7 +17,7 @@ interface DailySectionProps {
checkboxes: DailyCheckbox[];
onAddCheckbox: (text: string, type: DailyCheckboxType) => Promise<void>;
onToggleCheckbox: (checkboxId: string) => Promise<void>;
onUpdateCheckbox: (checkboxId: string, text: string, type: DailyCheckboxType, taskId?: string) => Promise<void>;
onUpdateCheckbox: (checkboxId: string, text: string, type: DailyCheckboxType, taskId?: string, date?: Date) => Promise<void>;
onDeleteCheckbox: (checkboxId: string) => Promise<void>;
onReorderCheckboxes: (date: Date, checkboxIds: string[]) => Promise<void>;
onToggleAll?: () => Promise<void>;

View File

@@ -10,12 +10,13 @@ import { Card } from '@/components/ui/Card';
import { SearchInput } from '@/components/ui/SearchInput';
import { StatusBadge } from '@/components/ui/StatusBadge';
import { tasksClient } from '@/clients/tasks-client';
import { formatDateForDateTimeInput, parseDateTimeInput } from '@/lib/date-utils';
interface EditCheckboxModalProps {
checkbox: DailyCheckbox;
isOpen: boolean;
onClose: () => void;
onSave: (text: string, type: DailyCheckboxType, taskId?: string) => Promise<void>;
onSave: (text: string, type: DailyCheckboxType, taskId?: string, date?: Date) => Promise<void>;
saving?: boolean;
}
@@ -29,6 +30,7 @@ export function EditCheckboxModal({
const [text, setText] = useState(checkbox.text);
const [type, setType] = useState<DailyCheckboxType>(checkbox.type);
const [taskId, setTaskId] = useState<string | undefined>(checkbox.taskId);
const [date, setDate] = useState<Date>(checkbox.date);
const [selectedTask, setSelectedTask] = useState<Task | undefined>(undefined);
const [allTasks, setAllTasks] = useState<Task[]>([]);
const [tasksLoading, setTasksLoading] = useState(false);
@@ -83,7 +85,7 @@ export function EditCheckboxModal({
if (!text.trim()) return;
try {
await onSave(text.trim(), type, taskId);
await onSave(text.trim(), type, taskId, date);
onClose();
} catch (error) {
console.error('Erreur lors de la sauvegarde:', error);
@@ -101,6 +103,7 @@ export function EditCheckboxModal({
setText(checkbox.text);
setType(checkbox.type);
setTaskId(checkbox.taskId);
setDate(checkbox.date);
};
const handleClose = () => {
@@ -161,6 +164,15 @@ export function EditCheckboxModal({
</div>
</div>
{/* Date/Heure */}
<Input
label="Date/Heure"
type="datetime-local"
value={formatDateForDateTimeInput(date)}
onChange={(e) => setDate(parseDateTimeInput(e.target.value))}
disabled={saving}
/>
{/* Liaison tâche (pour tous les types) */}
<div>
<label className="block text-sm font-medium text-[var(--foreground)] mb-2">