feat: program restrictions

This commit is contained in:
Jannat Patel
2024-11-21 17:10:24 +05:30
parent 582c7af12d
commit 64ed0b3e94
14 changed files with 190 additions and 137 deletions

View File

@@ -173,12 +173,14 @@ import { BookOpen, Plus, Search } from 'lucide-vue-next'
import { ref, computed, inject, onMounted, watch } from 'vue'
import { updateDocumentTitle } from '@/utils'
import { useRouter } from 'vue-router'
import { useSettings } from '@/stores/settings'
const user = inject('$user')
const searchQuery = ref('')
const currentCategory = ref(null)
const hasCourses = ref(false)
const router = useRouter()
const settings = useSettings()
onMounted(() => {
checkLearningPath()
@@ -189,14 +191,12 @@ onMounted(() => {
})
const checkLearningPath = () => {
call('frappe.client.get_single_value', {
doctype: 'LMS Settings',
field: 'enable_learning_paths',
}).then((res) => {
if (res && !user.data?.is_moderator && !user.data?.is_instructor) {
router.push({ name: 'Programs' })
}
})
if (
settings.learningPaths.data &&
(!user.data?.is_moderator || !user.data?.is_instructor)
) {
router.push({ name: 'Programs' })
}
}
const courses = createResource({