Skip to content

Commit 0471e61

Browse files
committed
fix: filter query (staffs)
1 parent b67ca7c commit 0471e61

File tree

5 files changed

+50
-32
lines changed

5 files changed

+50
-32
lines changed

apps/web/app/components/TeamPageSection.vue

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<script setup lang="ts">
22
import { team as teamData, volunteers } from '~/utils/constants'
3-
// import type { StaffInfo } from '@vuejs-jp/model'
4-
// import { useFetch, useRuntimeConfig } from '#imports'
3+
import type { StaffCategory, StaffInfo } from '@vuejs-jp/model'
4+
import { useRuntimeConfig } from '#imports'
55
6-
// type Staffs = Record<'allStaffs', StaffInfo>
6+
type Staffs = Record<StaffCategory, StaffInfo>
77
8-
// const config = useRuntimeConfig()
8+
const props = defineProps<{
9+
data: Staffs
10+
}>()
911
10-
// const { data, error } = await useFetch('/api/staffs')
11-
// if (error.value) {
12-
// console.error(error.value)
13-
// }
14-
// const { allStaffs } = data.value as Staffs
15-
// const team = config.public.staffDatasource === 'supabase' ? allStaffs.list : teamData
16-
const team = teamData
12+
const config = useRuntimeConfig()
13+
14+
const coreTeam = config.public.staffDatasource === 'supabase' ? props.data.coreStaffs.list : teamData
15+
const volunteerTeam = config.public.staffDatasource === 'supabase'
16+
? props.data.volunteerStaffs.list.map((staff) => staff.name)
17+
: volunteers
18+
// const team = teamData
1719
</script>
1820

1921
<template>
@@ -28,7 +30,7 @@ const team = teamData
2830
</div>
2931

3032
<div class="team-members-container">
31-
<div v-for="member in team" :key="member.name" class="team-member-wrapper">
33+
<div v-for="member in coreTeam" :key="member.name" class="team-member-wrapper">
3234
<template v-if="member.x_id !== ''">
3335
<a :href="`https://x.com/${member.x_id}`" target="_blank" :aria-label="member.name">
3436
<VFAvatar :src="member.image_url" :alt="member.name" />
@@ -39,7 +41,8 @@ const team = teamData
3941
target="_blank"
4042
:href="`https://x.com/${member.x_id}`"
4143
color="vue-blue"
42-
>{{ member.name }}
44+
>
45+
{{ member.x_id ?? member.github_id }}
4346
</VFTextLink>
4447
</div>
4548
</template>
@@ -59,7 +62,7 @@ const team = teamData
5962
</VFTitle>
6063

6164
<div class="volunteer-members-container">
62-
<VFCreditList :list="volunteers" />
65+
<VFCreditList :list="volunteerTeam" />
6366
</div>
6467
</article>
6568
</section>

apps/web/app/pages/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ const { data: sponsors, error: error2, refresh: refreshSponsor } = await useFetc
2121
if (error2.value) {
2222
console.error(error2.value)
2323
}
24+
const { data: staffs, error: error3, refresh: refreshStaff } = await useFetch('/api/staffs')
25+
if (error3.value) {
26+
console.error(error3.value)
27+
}
2428
2529
onMounted(function () {
2630
window.addEventListener('popstate', async function (event) {
2731
await refreshSpeaker()
2832
await refreshSponsor()
33+
await refreshStaff()
2934
await reloadNuxtApp()
3035
})
3136
})
@@ -52,5 +57,5 @@ useHead({
5257
<SponsorPageSection :data="sponsors" />
5358
<CooperationPartnerSection />
5459
<FormPageSection />
55-
<TeamPageSection />
60+
<TeamPageSection :data="staffs" />
5661
</template>

apps/web/app/server/api/staffs.get.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,22 @@ export default defineEventHandler(async (event) => {
1818
if (process.env.NODE_ENV === 'production') return staff.is_open === true && staff.is_volunteer === false
1919
return staff.is_volunteer === false
2020
})
21+
.filter(staff => staff.display_order !== null)
2122
.sort((a: Staff, b: Staff) => {
22-
if (a.display_order) return -1
23-
if (b.display_order) return 1
24-
if (!a.display_order) return a.name < b.name ? -1 : 1
25-
if (!b.display_order) return a.name < b.name ? -1 : 1
26-
return a.display_order - b.display_order
27-
}),
23+
if (b.display_order && a.display_order) return a.display_order - b.display_order
24+
return 1
25+
})
26+
.concat(
27+
staffs
28+
.filter((staff: Staff) => {
29+
if (process.env.NODE_ENV === 'production') return staff.is_open === true && staff.is_volunteer === false
30+
return staff.is_volunteer === false
31+
})
32+
.filter(staff => staff.display_order === null)
33+
.sort((a: Staff, b: Staff) => {
34+
return a.created_at < b.created_at ? -1 : 1
35+
}),
36+
),
2837
}
2938

3039
const volunteerStaffs: StaffInfo = {
@@ -36,11 +45,7 @@ export default defineEventHandler(async (event) => {
3645
return staff.is_volunteer === true
3746
})
3847
.sort((a: Staff, b: Staff) => {
39-
if (a.display_order) return -1
40-
if (b.display_order) return 1
41-
if (!a.display_order) return a.name < b.name ? -1 : 1
42-
if (!b.display_order) return a.name < b.name ? -1 : 1
43-
return a.display_order - b.display_order
48+
return a.created_at < b.created_at ? -1 : 1
4449
}),
4550
}
4651

apps/web/app/utils/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { TeamData } from '@vuejs-jp/model'
2+
13
export const conferenceTitle = 'Vue Fes Japan 2024'
24

35
export const ogDescription =
@@ -82,7 +84,7 @@ export const personalSponsors = [
8284
'Haruki Tetone',
8385
]
8486

85-
export const team = [
87+
export const team: TeamData[] = [
8688
{
8789
name: 'kazu_pon',
8890
image_url: 'team/kazu_pon.jpg',

packages/model/lib/staff.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@ export type StaffCategory =
22
| 'coreStaffs'
33
| 'volunteerStaffs'
44

5-
export type Staff = {
5+
export type Staff = TeamData & {
66
id?: string
7-
name: string
87
detail_page_id: string
9-
image_url: string
10-
x_id?: string
11-
github_id?: string
128
is_open: boolean
139
display_order?: number
1410
is_volunteer: boolean
1511
created_at: string
1612
updated_at: string
1713
}
1814

15+
export type TeamData = {
16+
name: string
17+
image_url: string
18+
x_id?: string
19+
github_id?: string
20+
}
21+
1922
export type StaffInfo = {
2023
type: 'core-staff' | 'volunteer-staff'
2124
title: string

0 commit comments

Comments
 (0)