Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ async function start(): Promise<void> {
}

function continueRun(c: Contestant): void {
const { update } = useCurrentGameStore()
update({ contestantId: c._id, contestantName: c.name, teamName: c.teamName })
updateCurrentGame({ contestantId: c._id, contestantName: c.name, teamName: c.teamName })
navigateTo('/chooseRank')
}
</script>
Expand Down
1 change: 1 addition & 0 deletions server/utils/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MongoClient } from 'mongodb'

let _db: Db | undefined

// TODO: Currently doesn't work, because Cloudflare Pages doesn't support tcp
export function getDB() {
if (!_db) {
const client = new MongoClient(import.meta.env.MONGO_URI as string, {})
Expand Down
6 changes: 6 additions & 0 deletions stores/contestants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export const useContestantsStore = defineStore('contestants', {
},
async update(payload: Contestant) {
const apiEndpoint = '/api/contestants'
const currentGameStore = useCurrentGameStore()
if (!payload._id) {
payload._id = currentGameStore.currentGame.contestantId
payload.name = currentGameStore.currentGame.contestantName
}

const res = await fetch(apiEndpoint, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
Expand Down