chore: identify user persona

This commit is contained in:
Jannat Patel
2025-04-18 18:05:57 +05:30
parent 57e477b17c
commit 5800ac67c4
7 changed files with 231 additions and 10 deletions

View File

@@ -96,6 +96,7 @@
import {
Breadcrumbs,
Button,
call,
createListResource,
FormControl,
Select,
@@ -107,6 +108,7 @@ import { BookOpen, Plus } from 'lucide-vue-next'
import { sessionStore } from '@/stores/session'
import { canCreateCourse } from '@/utils'
import CourseCard from '@/components/CourseCard.vue'
import router from '../router'
const user = inject('$user')
const dayjs = inject('$dayjs')
@@ -121,6 +123,7 @@ const currentTab = ref('Live')
const { brand } = sessionStore()
onMounted(() => {
identifyUserPersona()
setFiltersFromQuery()
updateCourses()
categories.value = [
@@ -145,16 +148,34 @@ const courses = createListResource({
pageLength: pageLength.value,
start: start.value,
onSuccess(data) {
let allCategories = data.map((course) => course.category)
allCategories = allCategories.filter(
(category, index) => allCategories.indexOf(category) === index && category
)
if (categories.value.length <= allCategories.length) {
updateCategories(data)
}
setCategories(data)
},
})
const setCategories = (data) => {
let allCategories = data.map((course) => course.category)
allCategories = allCategories.filter(
(category, index) => allCategories.indexOf(category) === index && category
)
if (categories.value.length <= allCategories.length) {
updateCategories(data)
}
}
const identifyUserPersona = () => {
if (user.data?.is_system_manager) {
call('frappe.client.get_count', {
doctype: 'LMS Course',
}).then((data) => {
if (!data) {
router.push({
name: 'PersonaForm',
})
}
})
}
}
const updateCourses = () => {
updateFilters()
courses.update({