Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/assets/vue/store/enrolledStore.js

37 lines
1.0 KiB

import { defineStore } from "pinia"
import axios from "axios"
import { ref } from "vue"
export const useEnrolledStore = defineStore("enrolledStore", () => {
// Reactive state to track if the user is enrolled in courses or sessions
const isEnrolledInCourses = ref(false)
const isEnrolledInSessions = ref(false)
const isInitialized = ref(false)
// Function to check enrollment status
async function checkEnrollments() {
try {
const { data } = await axios.get("/course/check-enrollments")
console.log("Check enrollments data:", data)
isEnrolledInCourses.value = data.isEnrolledInCourses
isEnrolledInSessions.value = data.isEnrolledInSessions
} catch (error) {
console.error("Error verifying enrollments:", error)
} finally {
isInitialized.value = true
}
}
// Function to initialize the store
async function initialize() {
await checkEnrollments()
}
return {
// Computed properties for reactivity
isEnrolledInCourses,
isEnrolledInSessions,
initialize,
isInitialized,
}
})