feat: unpublished activities are now hidden by default

This commit is contained in:
swve 2025-04-17 15:57:57 +02:00
parent e6d7e881e3
commit 46e06201fb
14 changed files with 83 additions and 42 deletions

View file

@ -10,7 +10,7 @@ import { mutate } from 'swr'
import { getAPIUrl } from '@services/config/config'
import { revalidateTags } from '@services/utils/ts/requests'
import { useLHSession } from '@components/Contexts/LHSessionContext'
import { useCourse } from '@components/Contexts/CourseContext'
interface ModifiedChapterInterface {
chapterId: string
chapterName: string
@ -25,6 +25,8 @@ function Chapter(props: any) {
const [selectedChapter, setSelectedChapter] = React.useState<
string | undefined
>(undefined)
const course = useCourse() as any;
const withUnpublishedActivities = course ? course.withUnpublishedActivities : false
async function updateChapterName(chapterId: string) {
if (modifiedChapter?.chapterId === chapterId) {
@ -32,7 +34,7 @@ function Chapter(props: any) {
name: modifiedChapter.chapterName,
}
await updateChapter(chapterId, modifiedChapterCopy, session.data?.tokens?.access_token)
await mutate(`${getAPIUrl()}chapters/course/${props.course_uuid}/meta`)
await mutate(`${getAPIUrl()}chapters/course/${props.course_uuid}/meta?with_unpublished_activities=${withUnpublishedActivities}`)
await revalidateTags(['courses'], props.orgslug)
router.refresh()
}