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.
34 lines
815 B
34 lines
815 B
import { defineStore } from "pinia"
|
|
import axios from "axios"
|
|
import { ref } from "vue"
|
|
|
|
export const useCourseSettings = defineStore("courseSettings", () => {
|
|
const isLoading = ref(false)
|
|
const settings = ref({})
|
|
|
|
async function loadCourseSettings(courseId) {
|
|
isLoading.value = true
|
|
try {
|
|
const { data } = await axios.get(`/platform-config/list/course_settings?cid=${courseId}`)
|
|
settings.value = data.settings
|
|
} catch (e) {
|
|
console.error("Error loading course settings:", e)
|
|
} finally {
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
|
|
function resetCourseSettings() {
|
|
settings.value = {}
|
|
}
|
|
|
|
const getSetting = (variable) => settings.value[variable] || null
|
|
|
|
return {
|
|
isLoading,
|
|
settings,
|
|
loadCourseSettings,
|
|
resetCourseSettings,
|
|
getSetting
|
|
};
|
|
});
|
|
|