diff --git a/pages/index.vue b/pages/index.vue index 0ab4246..f99c20c 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -57,8 +57,7 @@ async function start(): Promise { } 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') } diff --git a/server/utils/db.ts b/server/utils/db.ts index 78a5bf9..2f68241 100644 --- a/server/utils/db.ts +++ b/server/utils/db.ts @@ -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, {}) diff --git a/stores/contestants.ts b/stores/contestants.ts index ea0240c..fa3cfda 100644 --- a/stores/contestants.ts +++ b/stores/contestants.ts @@ -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' },