fix: cleanup ui

This commit is contained in:
Jannat Patel
2024-02-05 17:35:46 +05:30
parent 4b9d3bd996
commit af48ccfb57
10 changed files with 185 additions and 2559 deletions

View File

@@ -52,10 +52,12 @@
<script setup>
import { Star } from 'lucide-vue-next'
import { createResource, Button } from 'frappe-ui'
import { computed, ref } from 'vue'
import { computed, ref, inject } from 'vue'
import UserAvatar from '@/components/UserAvatar.vue'
import ReviewModal from '@/components/Modals/ReviewModal.vue'
const user = inject('$user')
const props = defineProps({
courseName: {
type: String,
@@ -81,12 +83,9 @@ const hasReviewed = createResource({
owner: props.membership?.member,
},
},
auto: true,
auto: user.data?.name ? true : false,
})
const reversedRange = (count) =>
Array.from({ length: count }, (_, index) => count - index)
const reviews = createResource({
url: 'lms.lms.utils.get_reviews',
cache: ['course_reviews', props.courseName],
@@ -96,26 +95,6 @@ const reviews = createResource({
auto: true,
})
const rating_percent = computed(() => {
let rating_count = {}
let rating_percent = {}
for (const key of [1, 2, 3, 4, 5]) {
rating_count[key] = 0
}
for (const review of reviews?.data) {
rating_count[review.rating] += 1
}
;[1, 2, 3, 4, 5].forEach((key) => {
rating_percent[key] = (
(rating_count[key] / reviews.data.length) *
100
).toFixed(2)
})
return rating_percent
})
const showReviewModal = ref(false)
function openReviewModal() {