feat: add active match link in dashboard; display when user has an active match
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { db } from '$lib/server/db';
|
import { db } from '$lib/server/db';
|
||||||
import { match, team, mappool } from '$lib/server/db/schema';
|
import { match, team, mappool } from '$lib/server/db/schema';
|
||||||
import { eq, desc, count, inArray } from 'drizzle-orm';
|
import { eq, desc, count, inArray } from 'drizzle-orm';
|
||||||
|
import { getQueueStatus } from '$lib/server/match/engine';
|
||||||
import type { PageServerLoad } from './$types';
|
import type { PageServerLoad } from './$types';
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ locals }) => {
|
export const load: PageServerLoad = async ({ locals }) => {
|
||||||
@@ -35,10 +36,14 @@ export const load: PageServerLoad = async ({ locals }) => {
|
|||||||
.from(match)
|
.from(match)
|
||||||
.where(eq(match.state, 'FINISHED'));
|
.where(eq(match.state, 'FINISHED'));
|
||||||
|
|
||||||
|
const queueStatus = await getQueueStatus(locals.user.id);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
authenticated: true as const,
|
authenticated: true as const,
|
||||||
recentMatches,
|
recentMatches,
|
||||||
liveMatches,
|
liveMatches,
|
||||||
|
hasActiveMatch: !!queueStatus.matchedMatchId,
|
||||||
|
activeMatchId: queueStatus.matchedMatchId ?? null,
|
||||||
stats: {
|
stats: {
|
||||||
matches: matchCount.count,
|
matches: matchCount.count,
|
||||||
finished: finishedCount.count,
|
finished: finishedCount.count,
|
||||||
|
|||||||
@@ -225,6 +225,13 @@
|
|||||||
Leave Queue
|
Leave Queue
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{:else if data.hasActiveMatch}
|
||||||
|
<a
|
||||||
|
href="/matches/{data.activeMatchId}"
|
||||||
|
class="rounded-md border border-accent/40 px-4 py-2 text-sm font-600 text-accent transition-colors hover:bg-accent/10"
|
||||||
|
>
|
||||||
|
View Active Match →
|
||||||
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
onclick={joinQueue}
|
onclick={joinQueue}
|
||||||
|
|||||||
Reference in New Issue
Block a user