match h2h

This commit is contained in:
yohlo
2025-10-11 13:40:12 -05:00
parent 14c2eb2c02
commit 43972b6a06
6 changed files with 383 additions and 23 deletions

View File

@@ -347,3 +347,35 @@ export const getMatchReactions = createServerFn()
return reactions as Reaction[]
})
);
const matchesBetweenPlayersSchema = z.object({
player1Id: z.string(),
player2Id: z.string(),
});
export const getMatchesBetweenPlayers = createServerFn()
.inputValidator(matchesBetweenPlayersSchema)
.middleware([superTokensFunctionMiddleware])
.handler(async ({ data: { player1Id, player2Id } }) =>
toServerResult(async () => {
logger.info("Getting matches between players", { player1Id, player2Id });
const matches = await pbAdmin.getMatchesBetweenPlayers(player1Id, player2Id);
return matches;
})
);
const matchesBetweenTeamsSchema = z.object({
team1Id: z.string(),
team2Id: z.string(),
});
export const getMatchesBetweenTeams = createServerFn()
.inputValidator(matchesBetweenTeamsSchema)
.middleware([superTokensFunctionMiddleware])
.handler(async ({ data: { team1Id, team2Id } }) =>
toServerResult(async () => {
logger.info("Getting matches between teams", { team1Id, team2Id });
const matches = await pbAdmin.getMatchesBetweenTeams(team1Id, team2Id);
return matches;
})
);