From ac8e8d978c65ff1de888765f0dbd6b07510df591 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 20 May 2026 12:31:31 +0000 Subject: [PATCH] Add "no notes" item --- .../src/components/editors/NotesEditor.tsx | 82 +++++++++++-------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/src/frontend/src/components/editors/NotesEditor.tsx b/src/frontend/src/components/editors/NotesEditor.tsx index 8d775dcd7e..0a191d0707 100644 --- a/src/frontend/src/components/editors/NotesEditor.tsx +++ b/src/frontend/src/components/editors/NotesEditor.tsx @@ -18,6 +18,7 @@ import { BlockNoteView } from '@blocknote/mantine'; import '@blocknote/mantine/style.css'; import { useCreateBlockNote } from '@blocknote/react'; import { + Alert, Box, Button, Flex, @@ -27,7 +28,7 @@ import { Tabs, Text } from '@mantine/core'; -import { IconCirclePlus } from '@tabler/icons-react'; +import { IconCirclePlus, IconInfoCircle } from '@tabler/icons-react'; import { useNoteFields } from '../../forms/CommonForms'; import { useCreateApiFormModal } from '../../hooks/UseForm'; import { useUserState } from '../../states/UserState'; @@ -88,10 +89,15 @@ export default function NotesEditor({ () => user.hasChangePermission(modelType) && notesQuery.isFetched && - notesQuery.isSuccess, + notesQuery.isSuccess && + !!notesQuery.data, [user, modelType, notesQuery] ); + const hasNotes = useMemo(() => { + return notesQuery.data && notesQuery.data.length > 0; + }, [notesQuery.data]); + const editor = useCreateBlockNote(); const noteFields = useNoteFields({ modelType: modelType, modelId: modelId }); @@ -115,39 +121,49 @@ export default function NotesEditor({ {createNote.modal} - - + + {hasNotes ? ( + + + + ) : ( + }> + {t`There are no notes yet for this item.`} + + )} - - - - - {notesQuery.data?.map((note: any) => ( - setSelectedNote(note.pk)} - > - - {note.title} - - - ))} - - - + + + + + + {notesQuery.data?.map((note: any) => ( + setSelectedNote(note.pk)} + > + + {note.title} + + + ))} + + + + );