mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-11 05:05:07 -05:00
* Layout initial * Add FillRosterSection component * Move tournaments to feature folder * Refactor Button props * SubmitButton * Register action * Identifier -> Id * Invite link via nanoid * Team info submit * Enter tiebreaker map list UI * Invite members to tournament team initial * Show banner if joined a team not captain of * Add back teams page * Change team roster size color when good * Delete tournament team member
38 lines
893 B
TypeScript
38 lines
893 B
TypeScript
import { sql } from "~/db/sql";
|
|
import type { TournamentTeam } from "~/db/types";
|
|
import type { MapPool } from "~/modules/map-pool-serializer";
|
|
|
|
const deleteCounterpickMapsByTeamIdStm = sql.prepare(/* sql */ `
|
|
delete from
|
|
"MapPoolMap"
|
|
where
|
|
"tournamentTeamId" = @tournamentTeamId
|
|
`);
|
|
|
|
const addCounterpickMapStm = sql.prepare(/* sql */ `
|
|
insert into
|
|
"MapPoolMap" ("tournamentTeamId", "stageId", "mode")
|
|
values
|
|
(@tournamentTeamId, @stageId, @mode)
|
|
`);
|
|
|
|
export const upsertCounterpickMaps = sql.transaction(
|
|
({
|
|
tournamentTeamId,
|
|
mapPool,
|
|
}: {
|
|
tournamentTeamId: TournamentTeam["id"];
|
|
mapPool: MapPool;
|
|
}) => {
|
|
deleteCounterpickMapsByTeamIdStm.run({ tournamentTeamId });
|
|
|
|
for (const { stageId, mode } of mapPool.stageModePairs) {
|
|
addCounterpickMapStm.run({
|
|
tournamentTeamId,
|
|
stageId,
|
|
mode,
|
|
});
|
|
}
|
|
}
|
|
);
|