From e13652a753119dfa787a161942a06fd35ffa7664 Mon Sep 17 00:00:00 2001 From: gilles Date: Sun, 13 Sep 2026 17:47:13 +0200 Subject: [PATCH] refactor(notes): split NoteEditor into NoteForm and NoteReadView --- src/components/NoteEditor.tsx | 123 +++------------------------ src/components/NoteForm.tsx | 71 ++++++++++++++++ src/components/NoteReadView.test.tsx | 59 +++++++++++++ src/components/NoteReadView.tsx | 46 ++++++++++ src/interfaces/note-editor.ts | 6 ++ 5 files changed, 195 insertions(+), 110 deletions(-) create mode 100644 src/components/NoteForm.tsx create mode 100644 src/components/NoteReadView.test.tsx create mode 100644 src/components/NoteReadView.tsx diff --git a/src/components/NoteEditor.tsx b/src/components/NoteEditor.tsx index 76b24df..d660248 100644 --- a/src/components/NoteEditor.tsx +++ b/src/components/NoteEditor.tsx @@ -1,82 +1,14 @@ import { useState } from 'react' -import type { NoteEditorProps, NoteFormProps } from '../interfaces/note-editor' +import type { NoteEditorProps } from '../interfaces/note-editor' import { isTitleValid, normalizeTitle } from '../lib/noteValidation' -import DeleteModal from './DeleteModal' - -const TITLE_REQUIRED_MESSAGE = 'Le titre est obligatoire.' - -function NoteForm({ - title, - content, - titleMissing, - cancelLabel, - onTitleChange, - onContentChange, - onCancel, - onSubmit, -}: NoteFormProps) { - return ( -
{ - event.preventDefault() - onSubmit() - }} - > - - {titleMissing && ( - - {TITLE_REQUIRED_MESSAGE} - - )} -