-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
182 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import { f7Pagea } from 'framework7-vue' | ||
</script> | ||
|
||
<template> | ||
<f7Page> | ||
event | ||
</f7Page> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script setup lang="ts"> | ||
import dayjs from 'dayjs' | ||
const { data: events } = useEvents() | ||
</script> | ||
|
||
<template> | ||
<div class="data-table data-table-init card"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th class="label-cell"> | ||
Name | ||
</th> | ||
<th class="label-cell"> | ||
Start date | ||
</th> | ||
<th class="label-cell"> | ||
End date | ||
</th> | ||
<th class="numeric-label"> | ||
Participants | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="event in events" :key="event.id"> | ||
<td class="label-cell"> | ||
{{ event.name }} | ||
</td> | ||
<td class="label-cell"> | ||
{{ dayjs(event.startDateTime).format('DD-MM-YYYY hh:mm') }} | ||
</td> | ||
<td class="label-cell"> | ||
{{ dayjs(event.endDateTime).format('DD-MM-YYYY hh:mm') }} | ||
</td> | ||
<td class="numeric-cell"> | ||
{{ event.attendees.length }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useQuery, useQueryClient } from '@tanstack/vue-query' | ||
import type { EventWithAttendees } from '~/shared/types' | ||
|
||
const queryKeyFactory = { | ||
events: ['events'], | ||
event: (id: string) => ['events', id], | ||
} | ||
|
||
export function useEvents() { | ||
const firebaseCurrentUser = useCurrentUser() | ||
return useQuery({ | ||
queryKey: queryKeyFactory.events, | ||
queryFn: () => $api<EventWithAttendees[]>('/api/event'), | ||
enabled: computed(() => !!firebaseCurrentUser.value), // Only run when user exists | ||
}) | ||
} | ||
|
||
export function useEvent(id: string) { | ||
const firebaseCurrentUser = useCurrentUser() | ||
const queryClient = useQueryClient() | ||
return useQuery({ | ||
queryKey: queryKeyFactory.events, | ||
queryFn: () => $api<EventWithAttendees>('/api/event'), | ||
enabled: computed(() => !!firebaseCurrentUser.value), // Only run when user exists | ||
placeholderData() { | ||
return queryClient.getQueryData<EventWithAttendees[]>(queryKeyFactory.events)?.find(event => event.id === id) | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import dayjs from 'dayjs' | ||
|
||
export default defineProtectedEventHandler(event => ({ | ||
id: event.context.params!.id, | ||
name: 'SST Homecoming 2024', | ||
description: 'SST Homecoming 2024', | ||
location: 'SST', | ||
badgeImage: 'https://www.sst.edu.sg/images/default-source/album/2019-2020/2020-01-24-homecoming/20200124_182000.jpg?sfvrsn=2', | ||
startDateTime: dayjs(Date.now()).valueOf(), | ||
endDateTime: dayjs(Date.now()).valueOf(), | ||
attendees: [ | ||
{ | ||
id: '123', | ||
name: 'Qin Guan', | ||
admissionKey: '123', | ||
}, | ||
], | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import dayjs from 'dayjs' | ||
|
||
export default defineProtectedEventHandler(event => ({ | ||
id: event.context.params!.id, | ||
name: 'SST Homecoming 2024', | ||
description: 'SST Homecoming 2024', | ||
location: 'SST', | ||
badgeImage: 'https://www.sst.edu.sg/images/default-source/album/2019-2020/2020-01-24-homecoming/20200124_182000.jpg?sfvrsn=2', | ||
startDateTime: dayjs(Date.now()).valueOf(), | ||
endDateTime: dayjs(Date.now()).valueOf(), | ||
attendees: [ | ||
{ | ||
id: '123', | ||
name: 'Qin Guan', | ||
admissionKey: '123', | ||
}, | ||
], | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import dayjs from 'dayjs' | ||
|
||
export default defineProtectedEventHandler(event => [{ | ||
id: event.context.params!.id, | ||
name: 'SST Homecoming 2024', | ||
description: 'SST Homecoming 2024', | ||
location: 'SST', | ||
badgeImage: 'https://www.sst.edu.sg/images/default-source/album/2019-2020/2020-01-24-homecoming/20200124_182000.jpg?sfvrsn=2', | ||
startDateTime: dayjs(Date.now()).valueOf(), | ||
endDateTime: dayjs(Date.now()).valueOf(), | ||
attendees: [ | ||
{ | ||
id: '123', | ||
name: 'Qin Guan', | ||
admissionKey: '123', | ||
}, | ||
], | ||
}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import type { InferSelectModel } from 'drizzle-orm' | ||
import type { users } from '~/server/db/schema' | ||
import type { events, users } from '~/server/db/schema' | ||
|
||
export type User = InferSelectModel<typeof users> | ||
export type UserRestricted = Pick<User, 'id' | 'name'> | ||
export type UserRestrictedWithAdmissionKey = UserRestricted & { admissionKey: string } | ||
|
||
export type Event = InferSelectModel<typeof events> | ||
export type EventWithAttendees = Event & { attendees: UserRestrictedWithAdmissionKey[] } |