fix
This commit is contained in:
@@ -1230,7 +1230,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
const [notesModalOpen, setNotesModalOpen] = useState(false)
|
||||
const [contextNoteMenu, setContextNoteMenu] = useState<{ x: number; y: number; text: string } | null>(null)
|
||||
const [completedSectionIds, setCompletedSectionIds] = useState<string[]>([])
|
||||
const [progressLoading, setProgressLoading] = useState(false)
|
||||
const [progressSaving, setProgressSaving] = useState(false)
|
||||
const [progressMessage, setProgressMessage] = useState('')
|
||||
const [checkpointAnswers, setCheckpointAnswers] = useState<Record<number, string>>({})
|
||||
@@ -1277,7 +1276,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
useEffect(() => {
|
||||
if (!auth.checked || !auth.authenticated || !study || !isEnrolled) return
|
||||
let cancelled = false
|
||||
setProgressLoading(true)
|
||||
setProgressMessage('')
|
||||
|
||||
readJson<{ studySlug: string; completedSectionIds: string[] }>(`/api/study-progress/${encodeURIComponent(currentStudySlug)}`)
|
||||
@@ -1291,7 +1289,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
})
|
||||
.finally(() => {
|
||||
if (cancelled) return
|
||||
setProgressLoading(false)
|
||||
})
|
||||
|
||||
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() {
|
||||
if (!noteId || !canSaveNote) return
|
||||
setNoteSaving(true)
|
||||
@@ -1423,40 +1405,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
return () => window.removeEventListener('mousedown', handleClick)
|
||||
}, [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() {
|
||||
if (!study || !section?.id || progressSaving) return
|
||||
const checkpointQuestions = section.checkpointQuestions ?? []
|
||||
|
||||
Reference in New Issue
Block a user