refactor(notes): use shared types and interfaces in components

This commit is contained in:
devcodetools committed 2026-09-13 16:49:14 +02:00
1 parent 2975b80a94
commit 557e48116a
12 files changed
+16 -57

No files matched your search

+1 -6
View File
@@ -1,9 +1,4 @@
interface DeleteModalProps {
open: boolean
title: string
onConfirm: () => void
onCancel: () => void
}
import type { DeleteModalProps } from '../interfaces/delete-modal'
function DeleteModal({ open, title, onConfirm, onCancel }: DeleteModalProps) {
if (!open) return null
+1 -4
View File
@@ -1,7 +1,4 @@
interface FloatingButtonProps {
onClick: () => void
label?: string
}
import type { FloatingButtonProps } from '../interfaces/floating-button'
function FloatingButton({ onClick, label = 'Créer une note' }: FloatingButtonProps) {
return (
+1 -1
View File
@@ -1,7 +1,7 @@
import { fireEvent, render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import NoteEditor from './NoteEditor'
import type { Note } from '../types'
import type { Note } from '../types/note'
const note: Note = { id: 42, title: 'Courses', content: 'Lait\nOeufs' }
+4 -27
View File
@@ -1,33 +1,10 @@
import { useState } from 'react'
import type { Note } from '../types'
import type {
NoteEditorProps,
NoteFormProps,
} from '../interfaces/note-editor'
import DeleteModal from './DeleteModal'
interface EditEditorProps {
mode: 'edit'
note: Note
onUpdate: (id: number, patch: Partial<Pick<Note, 'title' | 'content'>>) => void
onDelete: (id: number) => void
}
interface CreateEditorProps {
mode: 'create'
onCreate: (title: string, content: string) => void
onCancelCreate: () => void
}
type NoteEditorProps = EditEditorProps | CreateEditorProps
interface NoteFormProps {
title: string
content: string
titleMissing: boolean
cancelLabel: string
onTitleChange: (value: string) => void
onContentChange: (value: string) => void
onCancel: () => void
onSubmit: () => void
}
const TITLE_REQUIRED_MESSAGE = 'Le titre est obligatoire.'
function NoteForm({
+1 -1
View File
@@ -1,7 +1,7 @@
import { fireEvent, render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import NoteList from './NoteList'
import type { Note } from '../types'
import type { Note } from '../types/note'
const notes: Note[] = [
{ id: 3, title: 'Courses', content: 'Lait' },
+1 -6
View File
@@ -1,9 +1,4 @@
import type { Note } from '../types'
interface NoteListProps {
notes: Note[]
onSelect: (id: number) => void
}
import type { NoteListProps } from '../interfaces/note-list'
const EMPTY_MESSAGE = 'Aucune note pour le moment.\nTouchez + pour en créer une.'