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