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:
@@ -103,12 +103,17 @@ export function DailyPageClient({
|
|||||||
await refreshDailyDates();
|
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, {
|
await updateCheckbox(checkboxId, {
|
||||||
text,
|
text,
|
||||||
type,
|
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[]) => {
|
const handleReorderCheckboxes = async (date: Date, checkboxIds: string[]) => {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { EditCheckboxModal } from './EditCheckboxModal';
|
|||||||
interface DailyCheckboxItemProps {
|
interface DailyCheckboxItemProps {
|
||||||
checkbox: DailyCheckbox;
|
checkbox: DailyCheckbox;
|
||||||
onToggle: (checkboxId: string) => Promise<void>;
|
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>;
|
onDelete: (checkboxId: string) => Promise<void>;
|
||||||
saving?: boolean;
|
saving?: boolean;
|
||||||
}
|
}
|
||||||
@@ -93,8 +93,8 @@ export function DailyCheckboxItem({
|
|||||||
setEditingCheckbox(checkbox);
|
setEditingCheckbox(checkbox);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveAdvancedEdit = async (text: string, type: DailyCheckboxType, taskId?: string) => {
|
const handleSaveAdvancedEdit = async (text: string, type: DailyCheckboxType, taskId?: string, date?: Date) => {
|
||||||
await onUpdate(checkbox.id, text, type, taskId);
|
await onUpdate(checkbox.id, text, type, taskId, date);
|
||||||
setEditingCheckbox(null);
|
setEditingCheckbox(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ interface DailySectionProps {
|
|||||||
checkboxes: DailyCheckbox[];
|
checkboxes: DailyCheckbox[];
|
||||||
onAddCheckbox: (text: string, type: DailyCheckboxType) => Promise<void>;
|
onAddCheckbox: (text: string, type: DailyCheckboxType) => Promise<void>;
|
||||||
onToggleCheckbox: (checkboxId: string) => 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>;
|
onDeleteCheckbox: (checkboxId: string) => Promise<void>;
|
||||||
onReorderCheckboxes: (date: Date, checkboxIds: string[]) => Promise<void>;
|
onReorderCheckboxes: (date: Date, checkboxIds: string[]) => Promise<void>;
|
||||||
onToggleAll?: () => Promise<void>;
|
onToggleAll?: () => Promise<void>;
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ import { Card } from '@/components/ui/Card';
|
|||||||
import { SearchInput } from '@/components/ui/SearchInput';
|
import { SearchInput } from '@/components/ui/SearchInput';
|
||||||
import { StatusBadge } from '@/components/ui/StatusBadge';
|
import { StatusBadge } from '@/components/ui/StatusBadge';
|
||||||
import { tasksClient } from '@/clients/tasks-client';
|
import { tasksClient } from '@/clients/tasks-client';
|
||||||
|
import { formatDateForDateTimeInput, parseDateTimeInput } from '@/lib/date-utils';
|
||||||
|
|
||||||
interface EditCheckboxModalProps {
|
interface EditCheckboxModalProps {
|
||||||
checkbox: DailyCheckbox;
|
checkbox: DailyCheckbox;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onSave: (text: string, type: DailyCheckboxType, taskId?: string) => Promise<void>;
|
onSave: (text: string, type: DailyCheckboxType, taskId?: string, date?: Date) => Promise<void>;
|
||||||
saving?: boolean;
|
saving?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ export function EditCheckboxModal({
|
|||||||
const [text, setText] = useState(checkbox.text);
|
const [text, setText] = useState(checkbox.text);
|
||||||
const [type, setType] = useState<DailyCheckboxType>(checkbox.type);
|
const [type, setType] = useState<DailyCheckboxType>(checkbox.type);
|
||||||
const [taskId, setTaskId] = useState<string | undefined>(checkbox.taskId);
|
const [taskId, setTaskId] = useState<string | undefined>(checkbox.taskId);
|
||||||
|
const [date, setDate] = useState<Date>(checkbox.date);
|
||||||
const [selectedTask, setSelectedTask] = useState<Task | undefined>(undefined);
|
const [selectedTask, setSelectedTask] = useState<Task | undefined>(undefined);
|
||||||
const [allTasks, setAllTasks] = useState<Task[]>([]);
|
const [allTasks, setAllTasks] = useState<Task[]>([]);
|
||||||
const [tasksLoading, setTasksLoading] = useState(false);
|
const [tasksLoading, setTasksLoading] = useState(false);
|
||||||
@@ -83,7 +85,7 @@ export function EditCheckboxModal({
|
|||||||
if (!text.trim()) return;
|
if (!text.trim()) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await onSave(text.trim(), type, taskId);
|
await onSave(text.trim(), type, taskId, date);
|
||||||
onClose();
|
onClose();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la sauvegarde:', error);
|
console.error('Erreur lors de la sauvegarde:', error);
|
||||||
@@ -101,6 +103,7 @@ export function EditCheckboxModal({
|
|||||||
setText(checkbox.text);
|
setText(checkbox.text);
|
||||||
setType(checkbox.type);
|
setType(checkbox.type);
|
||||||
setTaskId(checkbox.taskId);
|
setTaskId(checkbox.taskId);
|
||||||
|
setDate(checkbox.date);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
@@ -161,6 +164,15 @@ export function EditCheckboxModal({
|
|||||||
</div>
|
</div>
|
||||||
</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) */}
|
{/* Liaison tâche (pour tous les types) */}
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-[var(--foreground)] mb-2">
|
<label className="block text-sm font-medium text-[var(--foreground)] mb-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user