diff --git a/frontend/src/pages/Batches.vue b/frontend/src/pages/Batches.vue index dd46a7bf..c7db7079 100644 --- a/frontend/src/pages/Batches.vue +++ b/frontend/src/pages/Batches.vue @@ -105,6 +105,7 @@ import { Select, TabButtons, } from 'frappe-ui' +import { useRouteQuery } from '@vueuse/router' import { computed, inject, onMounted, ref, watch } from 'vue' import { BookOpen, Plus } from 'lucide-vue-next' import { updateDocumentTitle } from '@/utils' @@ -119,7 +120,10 @@ const currentCategory = ref(null) const title = ref('') const certification = ref(false) const filters = ref({}) -const currentTab = ref(user.data?.is_student ? 'All' : 'Upcoming') +const currentTab = useRouteQuery( + 'tab', + user.data?.is_student ? 'All' : 'Upcoming' +) const orderBy = ref('start_date') onMounted(() => { @@ -250,7 +254,12 @@ const setQueryParams = () => { } }) - history.replaceState({}, '', `${location.pathname}?${queries.toString()}`) + let queryString = '' + if (queries.toString()) { + queryString = `?${queries.toString()}` + } + + history.replaceState({}, '', `${location.pathname}${queryString}`) } const updateCategories = (data) => { @@ -270,18 +279,6 @@ watch(currentTab, () => { updateBatches() }) -const batchType = computed(() => { - let types = [ - { label: __(''), value: null }, - { label: __('Upcoming'), value: 'Upcoming' }, - { label: __('Archived'), value: 'Archived' }, - ] - if (user.data?.is_moderator) { - types.push({ label: __('Unpublished'), value: 'Unpublished' }) - } - return types -}) - const batchTabs = computed(() => { let tabs = [ { diff --git a/frontend/src/pages/Courses.vue b/frontend/src/pages/Courses.vue index 769b0121..c43ad88a 100644 --- a/frontend/src/pages/Courses.vue +++ b/frontend/src/pages/Courses.vue @@ -105,6 +105,7 @@ import { Select, TabButtons, } from 'frappe-ui' +import { useRouteQuery } from '@vueuse/router' import { computed, inject, onMounted, ref, watch } from 'vue' import { BookOpen, Plus } from 'lucide-vue-next' import { updateDocumentTitle } from '@/utils' @@ -119,7 +120,7 @@ const currentCategory = ref(null) const title = ref('') const certification = ref(false) const filters = ref({}) -const currentTab = ref('Live') +const currentTab = useRouteQuery('tab', 'Live') onMounted(() => { setFiltersFromQuery() @@ -255,7 +256,12 @@ const setQueryParams = () => { } }) - history.replaceState({}, '', `${location.pathname}?${queries.toString()}`) + let queryString = '' + if (queries.toString()) { + queryString = `?${queries.toString()}` + } + + history.replaceState({}, '', `${location.pathname}${queryString}`) } const updateCategories = (data) => { @@ -275,21 +281,6 @@ watch(currentTab, () => { updateCourses() }) -const courseType = computed(() => { - let types = [ - { label: __(''), value: null }, - { label: __('New'), value: 'New' }, - { label: __('Upcoming'), value: 'Upcoming' }, - ] - if (user.data?.is_student) { - types.push({ label: __('Enrolled'), value: 'Enrolled' }) - } - if (user.data?.is_moderator || user.data?.is_instructor) { - types.push({ label: __('Created'), value: 'Created' }) - } - return types -}) - const courseTabs = computed(() => { let tabs = [ {