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/views/user/courses/List.vue

49 lines
1.1 KiB

<template>
<div class="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mt-2">
{{ status }}
<CourseCardList
:courses="courses"
/>
</div>
</template>
<script>
import CourseCardList from '../../../components/course/CourseCardList.vue';
import {ENTRYPOINT} from '../../../config/entrypoint';
import axios from "axios";
4 years ago
import {ref, computed} from "vue";
import { useStore } from 'vuex';
export default {
name: 'CourseList',
components: {
CourseCardList,
},
4 years ago
setup() {
const courses = ref([]);
const status = ref('Loading');
const store = useStore();
let user = computed(() => store.getters['security/getUser']);
if (user.value) {
let userId = user.value.id;
axios.get(ENTRYPOINT + 'users/' + userId + '/courses.json').then(response => {
if (Array.isArray(response.data)) {
courses.value = response.data;
}
}).catch(function (error) {
console.log(error);
}).finally(() =>
status.value = ''
);
}
return {
4 years ago
courses,
status
}
}
};
</script>