* Refactor usage of useResult with a computed since is deprecated * Improve validation of sessions composable and add the possibility to configure the querypull/4771/head
parent
f88d9f68ca
commit
f1293a3377
@ -1,45 +1,33 @@ |
||||
<template> |
||||
<div v-if="courses.length" class="mb-6"> |
||||
<h2> {{ $t('Sticky courses')}}</h2> |
||||
<h2 class="mb-2"> {{ $t('Sticky courses')}}</h2> |
||||
<div |
||||
class="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mt-2"> |
||||
v-if="courses.length" |
||||
class="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mt-2" |
||||
> |
||||
<CourseCardList |
||||
:courses="courses" |
||||
:courses="courses" |
||||
/> |
||||
</div> |
||||
<hr /> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import CourseCardList from '../../../components/course/CourseCardList.vue'; |
||||
import {computed} from "vue"; |
||||
import {useStore} from 'vuex'; |
||||
import {useQuery, useResult} from '@vue/apollo-composable' |
||||
import {GET_STICKY_COURSES} from "../../../graphql/queries/Course"; |
||||
<script setup> |
||||
import CourseCardList from '../../../components/course/CourseCardList.vue' |
||||
import {computed} from "vue" |
||||
import {useStore} from 'vuex' |
||||
import {GET_STICKY_COURSES} from "../../../graphql/queries/Course" |
||||
import {useSession} from "../sessions/session" |
||||
|
||||
export default { |
||||
name: 'StickyCourses', |
||||
components: { |
||||
CourseCardList, |
||||
}, |
||||
setup() { |
||||
const store = useStore(); |
||||
let user = computed(() => store.getters['security/getUser']); |
||||
const store = useStore() |
||||
|
||||
if (user.value) { |
||||
const {result: resultStickyCourses, loading: loadingCourses} = useQuery(GET_STICKY_COURSES); |
||||
const courses = useResult(resultStickyCourses, [], (data) => { |
||||
return data.courses.edges.map(function (edge) { |
||||
return edge.node; |
||||
}); |
||||
}); |
||||
let user = computed(() => store.getters['security/getUser']) |
||||
const {sessions: result} = useSession(user, null, null, GET_STICKY_COURSES) |
||||
|
||||
return { |
||||
courses, |
||||
loadingCourses |
||||
} |
||||
} |
||||
const courses = computed(() => { |
||||
if (result.value === null) { |
||||
return [] |
||||
} |
||||
}; |
||||
return result.value |
||||
}) |
||||
</script> |
||||
|
Loading…
Reference in new issue