feat: Add course discovery page for browsing, filtering, and viewing course details.
This commit is contained in:
parent
8f38f795e6
commit
0c369d1197
1 changed files with 25 additions and 9 deletions
|
|
@ -99,16 +99,30 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
// Filter Logic based on search query
|
||||
// Filter Logic based on search query and category
|
||||
const selectedCategoryIds = ref<number[]>([]);
|
||||
|
||||
const filteredCourses = computed(() => {
|
||||
if (!searchQuery.value) return courses.value;
|
||||
const query = searchQuery.value.toLowerCase();
|
||||
return courses.value.filter(
|
||||
(c) => {
|
||||
const title = getLocalizedText(c.title).toLowerCase();
|
||||
const desc = getLocalizedText(c.description).toLowerCase();
|
||||
return title.includes(query) || (desc && desc.includes(query));
|
||||
}
|
||||
);
|
||||
let result = courses.value;
|
||||
|
||||
// Filter by Category
|
||||
if (selectedCategoryIds.value.length > 0) {
|
||||
result = result.filter(c => selectedCategoryIds.value.includes(c.category_id));
|
||||
}
|
||||
|
||||
// Filter by Search Query
|
||||
if (searchQuery.value) {
|
||||
const query = searchQuery.value.toLowerCase();
|
||||
result = result.filter(
|
||||
(c) => {
|
||||
const title = getLocalizedText(c.title).toLowerCase();
|
||||
const desc = getLocalizedText(c.description).toLowerCase();
|
||||
return title.includes(query) || (desc && desc.includes(query));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
@ -187,6 +201,8 @@ const filteredCourses = computed(() => {
|
|||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:value="cat.id"
|
||||
v-model="selectedCategoryIds"
|
||||
class="w-4 h-4 rounded border-slate-300 text-primary focus:ring-primary"
|
||||
/>
|
||||
{{ getLocalizedText(cat.name) }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue