diff --git a/app/[locale]/bible/reader.tsx b/app/[locale]/bible/reader.tsx
index 3b8615a..de8c430 100644
--- a/app/[locale]/bible/reader.tsx
+++ b/app/[locale]/bible/reader.tsx
@@ -80,7 +80,8 @@ import {
Storage,
MoreVert,
Star,
- StarBorder
+ StarBorder,
+ Edit
} from '@mui/icons-material'
interface BibleVerse {
@@ -242,9 +243,11 @@ export default function BibleReaderNew({ initialVersion, initialBook, initialCha
open: boolean
verse?: BibleVerse
note: string
+ highlightId?: string
}>({
open: false,
- note: ''
+ note: '',
+ highlightId: undefined
})
// Copy feedback
@@ -1243,6 +1246,58 @@ export default function BibleReaderNew({ initialVersion, initialBook, initialCha
handleVerseMenuClose()
}
+ const handleOpenNoteDialog = (verse: BibleVerse) => {
+ const highlight = highlights[verse.id]
+ setNoteDialog({
+ open: true,
+ verse,
+ note: highlight?.note || '',
+ highlightId: highlight?.id
+ })
+ setHighlightColorPickerAnchor({ element: null, verse: null })
+ handleVerseMenuClose()
+ }
+
+ const handleSaveNote = async () => {
+ if (!noteDialog.verse || !user) return
+
+ const token = localStorage.getItem('authToken')
+ if (!token) return
+
+ try {
+ const { verse, note, highlightId } = noteDialog
+
+ if (highlightId) {
+ // Update existing highlight's note
+ const response = await fetch(`/api/highlights/${highlightId}?locale=${locale}`, {
+ method: 'PUT',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${token}`
+ },
+ body: JSON.stringify({ note: note.trim() || null })
+ })
+
+ if (response.ok) {
+ const data = await response.json()
+ setHighlights(prev => ({
+ ...prev,
+ [verse.id]: data.highlight
+ }))
+ setCopyFeedback({
+ open: true,
+ message: note.trim() ? 'Note saved' : 'Note removed'
+ })
+ }
+ }
+
+ setNoteDialog({ open: false, note: '', highlightId: undefined })
+ } catch (error) {
+ console.error('Error saving note:', error)
+ alert('Failed to save note')
+ }
+ }
+
const handleSetFavoriteVersion = async () => {
if (!user) {
router.push(`/${locale}/login?redirect=${encodeURIComponent(`/${locale}/bible?version=${selectedVersion}&book=${selectedBook}&chapter=${selectedChapter}`)}`)
@@ -1451,6 +1506,28 @@ export default function BibleReaderNew({ initialVersion, initialBook, initialCha
)}
{verse.text}
+
+ {/* Display highlight note if it exists */}
+ {highlight?.note && (
+
+
+ Note:
+
+ {highlight.note}
+
+ )}
{highlightColorPickerAnchor.verse && highlights[highlightColorPickerAnchor.verse.id] && (
-
+ <>
+ }
+ onClick={() => {
+ if (highlightColorPickerAnchor.verse) {
+ handleOpenNoteDialog(highlightColorPickerAnchor.verse)
+ }
+ }}
+ >
+ {highlights[highlightColorPickerAnchor.verse.id].note ? 'Edit Note' : 'Add Note'}
+
+
+ >
)}
+ {/* Note Dialog */}
+
+
{/* Copy Feedback */}