This commit is contained in:
nmemmert
2026-06-02 14:21:03 -04:00
parent 3e050c8909
commit 01abb2c8c6
-52
View File
@@ -1230,7 +1230,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
const [notesModalOpen, setNotesModalOpen] = useState(false) const [notesModalOpen, setNotesModalOpen] = useState(false)
const [contextNoteMenu, setContextNoteMenu] = useState<{ x: number; y: number; text: string } | null>(null) const [contextNoteMenu, setContextNoteMenu] = useState<{ x: number; y: number; text: string } | null>(null)
const [completedSectionIds, setCompletedSectionIds] = useState<string[]>([]) const [completedSectionIds, setCompletedSectionIds] = useState<string[]>([])
const [progressLoading, setProgressLoading] = useState(false)
const [progressSaving, setProgressSaving] = useState(false) const [progressSaving, setProgressSaving] = useState(false)
const [progressMessage, setProgressMessage] = useState('') const [progressMessage, setProgressMessage] = useState('')
const [checkpointAnswers, setCheckpointAnswers] = useState<Record<number, string>>({}) const [checkpointAnswers, setCheckpointAnswers] = useState<Record<number, string>>({})
@@ -1277,7 +1276,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
useEffect(() => { useEffect(() => {
if (!auth.checked || !auth.authenticated || !study || !isEnrolled) return if (!auth.checked || !auth.authenticated || !study || !isEnrolled) return
let cancelled = false let cancelled = false
setProgressLoading(true)
setProgressMessage('') setProgressMessage('')
readJson<{ studySlug: string; completedSectionIds: string[] }>(`/api/study-progress/${encodeURIComponent(currentStudySlug)}`) readJson<{ studySlug: string; completedSectionIds: string[] }>(`/api/study-progress/${encodeURIComponent(currentStudySlug)}`)
@@ -1291,7 +1289,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
}) })
.finally(() => { .finally(() => {
if (cancelled) return if (cancelled) return
setProgressLoading(false)
}) })
return () => { return () => {
@@ -1360,21 +1357,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
} }
} }
async function logoutStudyUser() {
setAuthBusy(true)
setAuthMessage('')
try {
await readJson<{ ok: boolean }>('/api/study-auth/logout', { method: 'POST' })
setAuth({ checked: true, authenticated: false, username: '', enrolledStudySlugs: [] })
setNoteText('')
setAuthMessage('Signed out.')
} catch (err) {
setAuthMessage(err instanceof Error ? err.message : 'Unable to sign out.')
} finally {
setAuthBusy(false)
}
}
async function saveNote() { async function saveNote() {
if (!noteId || !canSaveNote) return if (!noteId || !canSaveNote) return
setNoteSaving(true) setNoteSaving(true)
@@ -1423,40 +1405,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
return () => window.removeEventListener('mousedown', handleClick) return () => window.removeEventListener('mousedown', handleClick)
}, [contextNoteMenu]) }, [contextNoteMenu])
async function markLessonComplete() {
if (!study || !section?.id || progressSaving) return
setProgressSaving(true)
setProgressMessage('')
try {
const data = await readJson<{ ok: boolean; completedSectionIds: string[] }>(`/api/study-progress/${encodeURIComponent(study.slug)}/${encodeURIComponent(section.id)}`, {
method: 'POST',
})
setCompletedSectionIds(Array.isArray(data.completedSectionIds) ? data.completedSectionIds : [])
setProgressMessage('Lesson marked complete.')
} catch (err) {
setProgressMessage(err instanceof Error ? err.message : 'Unable to update completion.')
} finally {
setProgressSaving(false)
}
}
async function unmarkLessonCompletion() {
if (!study || !section?.id || progressSaving) return
setProgressSaving(true)
setProgressMessage('')
try {
const data = await readJson<{ ok: boolean; completedSectionIds: string[] }>(`/api/study-progress/${encodeURIComponent(study.slug)}/${encodeURIComponent(section.id)}`, {
method: 'DELETE',
})
setCompletedSectionIds(Array.isArray(data.completedSectionIds) ? data.completedSectionIds : [])
setProgressMessage('Lesson marked incomplete.')
} catch (err) {
setProgressMessage(err instanceof Error ? err.message : 'Unable to update completion.')
} finally {
setProgressSaving(false)
}
}
async function submitCheckpoint() { async function submitCheckpoint() {
if (!study || !section?.id || progressSaving) return if (!study || !section?.id || progressSaving) return
const checkpointQuestions = section.checkpointQuestions ?? [] const checkpointQuestions = section.checkpointQuestions ?? []