Skip to content

Commit

Permalink
Merge branch 'main' of github.com:quintet-sdr/elect-gen-frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
projacktor committed Jul 22, 2024
2 parents fdffd3c + 2b06002 commit 1a618cf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
Binary file modified bun.lockb
100755 → 100644
Binary file not shown.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
"@nuxtjs/tailwindcss": "^6.12.0",
"@pinia/nuxt": "^0.5.1",
"@vueuse/head": "^2.0.0",
"black": "^0.3.0",
"mathjs": "^13.0.0",
"nuxt": "^3.12.2",
"pre-commit": "^1.2.2",
"pre-commit-hooks": "^0.9.22",
"vue": "^3.4.29",
"vue-router": "^4.3.3"
},
Expand Down
2 changes: 1 addition & 1 deletion pages/description.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ useHead({
<div
class="placeholder-p-4 bg-color-lightgray text-color-darkblue placeholder-color-gray w-full overflow-y-scroll rounded-3xl px-4 py-4 tablet:h-full laptop:h-80"
>
<!-- an example -->
<!-- an example f-->
<p>
This course aims to provide students with an introduction to the essential principles of
contemporary front-end web development, alongside a brief overview of its historical
Expand Down
50 changes: 28 additions & 22 deletions pages/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import type { Course, CourseGroup } from '~/server/utils/schemas'
definePageMeta({ layout: false })
useHead({
title: 'Select Electives - Elect.Gen',
meta: [{ name: 'description', content: 'Fill out the form with your five priorities.' }]
})
const NUM_OF_COURSES: number = 5
async function getSortedCourses(): Promise<void> {
sortedCourses.value = (await api.getCourses(currentElectiveType.value))?.sort((a, b) =>
async function setSortedCourses(elective: 'tech' | 'hum'): Promise<void> {
sortedCourses.value = (await api.getCourses(elective))?.sort((a, b) =>
a.short_name.localeCompare(b.short_name)
)
}
Expand Down Expand Up @@ -75,24 +80,14 @@ const items = [
const route = useRoute()
const router = useRouter()
function selectTab(value: number): void {
router.replace({
query: { type: items[value].type }
})
for (let i = 0; i < NUM_OF_COURSES; i += 1) {
selected.value[i] = undefined
}
}
const selectedTab = computed({
get() {
const index = items.findIndex((item) => item.type === route.query.type)
if (index === -1) {
return 0
}
;(async () => await getSortedCourses())()
;(async () => await setSortedCourses(route.query.type as 'tech' | 'hum'))()
return index
},
Expand Down Expand Up @@ -153,18 +148,29 @@ async function submit(): Promise<void> {
)
}
// FIXME
const x = await api.coursesGroups(currentElectiveType.value)
const courseGroups = ref(x !== undefined ? x.sort((a, b) => a.localeCompare(b)) : undefined)
const courseGroupsRaw = ref<CourseGroup[]>()
const courseGroupsSorted = computed(() =>
courseGroupsRaw !== undefined
? courseGroupsRaw.value?.sort((a, b) => a.localeCompare(b))
: undefined
)
const selectedGroup = ref<CourseGroup>()
onMounted(() => selectTab(0))
function selectTab(value: number): void {
router.replace({
query: { type: items[value].type }
})
useHead({
title: 'Select Electives - Elect.Gen',
meta: [{ name: 'description', content: 'Fill out the form with your five priorities.' }]
})
for (let i = 0; i < NUM_OF_COURSES; i += 1) {
selected.value[i] = undefined
}
;(async () =>
(courseGroupsRaw.value = await api.coursesGroups(items[value].type as 'hum' | 'tech')))()
}
onMounted(() => selectTab(0))
</script>

<template>
Expand Down Expand Up @@ -211,7 +217,7 @@ useHead({
<UFormGroup class="w-48 self-start" label="Course groups" required>
<USelectMenu
v-model="selectedGroup"
:options="courseGroups"
:options="courseGroupsSorted"
placeholder="Group…"
searchable
/>
Expand Down

0 comments on commit 1a618cf

Please sign in to comment.