Skip to content

Commit 861bd9c

Browse files
committed
update staff api
1 parent 8e82482 commit 861bd9c

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

apps/web/app/pages/sharemap.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { useFetch, useHead } from '#imports'
3-
import type { SpeakerCategory, SpeakerInfo, SponsorCategory, SponsorInfo, StaffInfo } from '@vuejs-jp/model'
3+
import type { SpeakerCategory, SpeakerInfo, SponsorCategory, SponsorInfo, StaffCategory, StaffInfo } from '@vuejs-jp/model'
44
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
55
import { conferenceTitle, linkUrl, ogSharemapDescription } from '~/utils/constants'
66
import { generalOg, twitterOg } from '~/utils/og.constants'
@@ -10,7 +10,7 @@ type Speakers = Record<_SpeakerCategory, SpeakerInfo>
1010
1111
type Sponsors = Record<SponsorCategory, SponsorInfo>
1212
13-
type Staffs = Record<'allStaffs', StaffInfo>
13+
type Staffs = Record<StaffCategory, StaffInfo>
1414
1515
const { data: speakers, error: error1 } = await useFetch('/api/speakers')
1616
const { sessionSpeakers, lightningTalkSpeakers, sponsorSessionSpeakers } = speakers.value as Speakers
@@ -39,7 +39,7 @@ if (error2.value) {
3939
console.error(error2.value)
4040
}
4141
const { data: staffs, error: error3 } = await useFetch('/api/staffs')
42-
const { allStaffs } = staffs.value as Staffs
42+
const { coreStaffs, volunteerStaffs } = staffs.value as Staffs
4343
if (error3.value) {
4444
console.error(error3.value)
4545
}
@@ -117,7 +117,7 @@ useHead({
117117
<div>
118118
<VFTitle id="staff">{{ $t('staff.title') }}</VFTitle>
119119
<VFTextLink
120-
v-for="staff in allStaffs.list"
120+
v-for="staff in [...coreStaffs.list, ...volunteerStaffs.list]"
121121
:key="staff.id"
122122
:href="`/staffs/${staff.detail_page_id}/share`"
123123
color="vue-blue"

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export default defineEventHandler(async (event) => {
1010
const { data: _staffs } = await client.from('staffs').select().order('display_order') as { data: Staff[] }
1111
staffs = _staffs
1212

13-
const allStaffs: StaffInfo = {
14-
type: 'staff',
15-
title: 'staff',
13+
const coreStaffs: StaffInfo = {
14+
type: 'core-staff',
15+
title: 'core-staff',
1616
list: staffs
1717
.filter((staff: Staff) => {
18-
if (process.env.NODE_ENV === 'production') return staff.is_open === true
19-
return true
18+
if (process.env.NODE_ENV === 'production') return staff.is_open === true && staff.is_volunteer === false
19+
return staff.is_volunteer === false
2020
})
2121
.sort((a: Staff, b: Staff) => {
2222
if (a.display_order) return -1
@@ -27,5 +27,22 @@ export default defineEventHandler(async (event) => {
2727
}),
2828
}
2929

30-
return { allStaffs }
30+
const volunteerStaffs: StaffInfo = {
31+
type: 'volunteer-staff',
32+
title: 'volunteer-staff',
33+
list: staffs
34+
.filter((staff: Staff) => {
35+
if (process.env.NODE_ENV === 'production') return staff.is_open === true && staff.is_volunteer === true
36+
return staff.is_volunteer === true
37+
})
38+
.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
44+
}),
45+
}
46+
47+
return { coreStaffs, volunteerStaffs }
3148
})

packages/model/lib/staff.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export type StaffCategory =
2+
| 'coreStaffs'
3+
| 'volunteerStaffs'
4+
15
export type Staff = {
26
id?: string
37
name: string
@@ -13,7 +17,7 @@ export type Staff = {
1317
}
1418

1519
export type StaffInfo = {
16-
type: 'staff'
20+
type: 'core-staff' | 'volunteer-staff'
1721
title: string
1822
list: Staff[]
1923
}

0 commit comments

Comments
 (0)