refactor(todos): formulaires création et édition migrés vers Modal

This commit is contained in:
2026-05-24 15:47:48 +02:00
parent 490d0d774f
commit 43736709a9
+5 -16
View File
@@ -4,6 +4,7 @@ import type { Todo, TodoCreate, TodoFilters } from '../api/todos'
import { fetchTodos, createTodo, updateTodo, deleteTodo, postponeTodo } from '../api/todos'
import SwipeableRow from '../components/todos/SwipeableRow'
import TodoForm from '../components/todos/TodoForm'
import Modal from '../components/Modal'
type EditingTodo = Todo | null
@@ -151,22 +152,14 @@ export default function TodosPage() {
{/* Formulaire de création */}
{showForm && (
<div className="glass" style={{ padding: 16, borderRadius: 10, marginBottom: 16 }}>
<div className="hidden lg:block">
<Modal title="Nouvelle tâche" onClose={() => setShowForm(false)}>
<TodoForm onSubmit={handleCreate} onCancel={() => setShowForm(false)} extended />
</div>
<div className="block lg:hidden">
<TodoForm onSubmit={handleCreate} onCancel={() => setShowForm(false)} />
</div>
</div>
</Modal>
)}
{/* Formulaire d'édition */}
{editingTodo && (
<div className="glass" style={{ padding: 16, borderRadius: 10, marginBottom: 16, borderLeft: '3px solid var(--accent)' }}>
<p style={{ color: 'var(--ink-3)', fontSize: 11, fontFamily: 'var(--font-ui)', marginBottom: 8, textTransform: 'uppercase', letterSpacing: 1 }}>
Modifier la tâche
</p>
<Modal title="Modifier la tâche" onClose={() => setEditingTodo(null)}>
<TodoForm
onSubmit={data => handleUpdate(editingTodo.id, data)}
onCancel={() => setEditingTodo(null)}
@@ -182,7 +175,7 @@ export default function TodosPage() {
tags: editingTodo.tags,
}}
/>
</div>
</Modal>
)}
{loading && (
@@ -377,7 +370,6 @@ export default function TodosPage() {
</div>
{/* FAB mobile (au-dessus de la barre de navigation) */}
{!showForm && (
<button
className="lg:hidden"
onClick={() => setShowForm(true)}
@@ -401,10 +393,8 @@ export default function TodosPage() {
lineHeight: 1,
}}
>+</button>
)}
{/* Bouton création laptop */}
{!showForm && (
<button
className="hidden lg:flex"
onClick={() => setShowForm(true)}
@@ -428,7 +418,6 @@ export default function TodosPage() {
>
+ Nouvelle tâche
</button>
)}
</div>
)
}