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.
45 lines
948 B
45 lines
948 B
import { defineStore } from "pinia";
|
|
import axios from "axios";
|
|
import { ref } from "vue";
|
|
|
|
export const usePlatformConfig = defineStore("platformConfig", () => {
|
|
const isLoading = ref(false);
|
|
const settings = ref(null);
|
|
const isStudentViewActive = ref(false);
|
|
|
|
function getSetting(variable) {
|
|
if (settings.value && settings.value[variable]) {
|
|
return settings.value[variable];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
async function findSettingsRequest() {
|
|
isLoading.value = true;
|
|
|
|
try {
|
|
const { data } = await axios.get("/platform-config/list")
|
|
|
|
settings.value = data.settings
|
|
|
|
isStudentViewActive.value = 'studentview' === data.studentview
|
|
} catch (e) {
|
|
console.log(e)
|
|
} finally {
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
|
|
async function initialize() {
|
|
await findSettingsRequest();
|
|
}
|
|
|
|
return {
|
|
isLoading,
|
|
settings,
|
|
isStudentViewActive,
|
|
initialize,
|
|
getSetting,
|
|
};
|
|
});
|
|
|