// Right-hand pane of the Study stage: commentary, word study, cross-references and // people & places, all driven by the selected chunk. import { useEffect, useState } from 'react'; import CommentaryChunkTab from './CommentaryChunkTab.jsx'; import WordStudyTab from './WordStudyTab.jsx'; import CrossRefsTab from './CrossRefsTab.jsx'; import PeopleChunkTab from './PeopleChunkTab.jsx'; import ReadingListTab from './ReadingListTab.jsx'; import IqChunkAids from '../iq/IqChunkAids.jsx'; import { useIqAvailable } from '../../hooks/useIq.js'; import { OBSERVE_FIRST_MIN, observeFirstDone, ownWords } from '../../utils/ownWork.js'; export const RESOURCE_TABS = [ { id: 'commentary', label: 'Commentary' }, { id: 'words', label: 'Word study' }, { id: 'refs', label: 'Cross-refs' }, { id: 'people', label: 'People & places' }, { id: 'readings', label: 'Reading list' }, { id: 'aids', label: 'Study aids', needsIq: true }, // shown only when the server has an IQ Bible key ]; export default function ResourcePane({ tab, setTab, chunk, chapter, chapterIndex, project, updateChunk, updateProject, notify, resources, wordStudy, crossRefs, openWordId, setOpenWordId }) { const iq = useIqAvailable(); const tabs = RESOURCE_TABS.filter((t) => !t.needsIq || iq); if (tab === 'aids' && !iq) tab = 'commentary'; // Commentary-type tabs wait for your own Observe notes (per chunk, until you choose to look anyway). const [unlocked, setUnlocked] = useState(() => new Set()); useEffect(() => { setUnlocked(new Set()); }, [chunk.id]); const held = (tab === 'commentary' || tab === 'aids') && !observeFirstDone(chunk) && !unlocked.has(chunk.id); // The first time commentary or study aids are on screen for a chunk, keep a copy of your notes as they were, // so you can later see what changed after reading others (shown under "More" in the notes). const seeing = (tab === 'commentary' || tab === 'aids') && !held; useEffect(() => { if (!seeing || chunk.firstDraft) return; updateChunk(chunk.id, { firstDraft: { at: Date.now(), observation: chunk.observation ?? '', interpretation: chunk.interpretation ?? '', application: chunk.application ?? '' } }, { touch: false }); }, [seeing, chunk.id, chunk.firstDraft]); // eslint-disable-line react-hooks/exhaustive-deps const counts = { words: chunk.greekWords.length, refs: (chunk.crossReferences ?? []).length, readings: (project?.readingList ?? []).filter((i) => !i.done).length }; return (
{tabs.map((t) => ( ))}
{held && (

Observe first

Write what you notice in the text before reading what others say. Commentary opens after {OBSERVE_FIRST_MIN} words of your own Observe notes ({ownWords(chunk, 'observation')} so far).

)} {!held && tab === 'commentary' && } {tab === 'words' && } {tab === 'refs' && } {tab === 'people' && } {tab === 'readings' && updateProject && } {!held && tab === 'aids' && }
); } export function useResourceTab() { const [tab, setTabState] = useState(() => { try { const saved = localStorage.getItem('studyResourceTab'); return RESOURCE_TABS.some((t) => t.id === saved) ? saved : 'commentary'; } catch { return 'commentary'; } }); const setTab = (id) => { setTabState(id); try { localStorage.setItem('studyResourceTab', id); } catch { /* storage unavailable */ } }; return [tab, setTab]; }