Skip to content

Commit

Permalink
Allow adding players in batch
Browse files Browse the repository at this point in the history
  • Loading branch information
aquarhead committed Sep 29, 2024
1 parent bba443d commit 411a82f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ async fn add_player(req: Request, ctx: RouteContext<AppCtx>) -> Result<Response>
return Response::error("player name can't be empty", 400);
}

let pid = random::hex_string();
team.players.insert(pid, name);
name.trim().split(',').for_each(|n| {
let pid = random::hex_string();
team.players.insert(pid, n.to_string());
});

return match teams_kv
.put(key, serde_json::to_string(&team).unwrap())?
Expand Down
3 changes: 2 additions & 1 deletion templates/team_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ <h1 class="title">
<form action="/admin/{{ key }}/{{ team.secret }}/player" method="post">
<div class="field has-addons">
<div class="control is-expanded">
<input type="text" name="player_name" class="input is-medium" placeholder="Player name">
<input type="text" name="player_name" class="input is-medium"
placeholder="Player name (use comma for multiple)">
</div>
<div class="control">
<button type="submit" class="button is-medium is-primary">
Expand Down

0 comments on commit 411a82f

Please sign in to comment.