Fix: show only proper join buttons

This commit is contained in:
Grail Finder
2025-06-27 18:37:29 +03:00
parent 86063a4f7e
commit f08aadc557
4 changed files with 59 additions and 10 deletions

View File

@ -40,13 +40,10 @@
<div class="flex justify-center">
<!-- Left Panel -->
{{template "teamlist" .Room.BlueTeam}}
{{if and (ne .State.Team "blue") (not .Room.IsRunning)}}
{{template "teampew" "blue"}}
{{if not .Room.IsRunning}}
{{template "teampew" .}}
{{end}}
<!-- Right Panel -->
{{if and (ne .State.Team "red") (not .Room.IsRunning)}}
{{template "teampew" "red"}}
{{end}}
{{template "teamlist" .Room.RedTeam}}
</div>
<hr />

View File

@ -1,18 +1,44 @@
{{define "teampew"}}
<div>
<h2 class="text-xl mb-4">Join {{.}} Team</h2>
<h2 class="text-xl mb-4">Join Blue Team</h2>
<form hx-post="/join-team" hx-target="#ancestor">
<input type="hidden" name="team" value="{{.}}">
<input type="hidden" name="team" value="blue">
<div class="mb-1">
<button type="submit" name="role" value="guesser" class="w-full bg-{{.}}-500 text-white py-2 px-4 rounded">
{{if and (eq .State.Role "guesser") (eq .State.Team "blue")}}
{{else}}
<button type="submit" name="role" value="guesser" class="w-full bg-blue-500 text-white py-2 px-4 rounded">
Join as Guesser
</button>
{{end}}
</div>
{{if eq .Room.BlueTeam.Mime ""}}
<div>
<button type="submit" name="role" value="mime" class="w-full bg-{{.}}-700 text-white py-2 px-4 rounded">
<button type="submit" name="role" value="mime" class="w-full bg-blue-700 text-white py-2 px-4 rounded">
Join as Mime
</button>
</div>
{{end}}
</form>
</div>
<div>
<h2 class="text-xl mb-4">Join Red Team</h2>
<form hx-post="/join-team" hx-target="#ancestor">
<input type="hidden" name="team" value="red">
<div class="mb-1">
{{if and (eq .State.Role "guesser") (eq .State.Team "red")}}
{{else}}
<button type="submit" name="role" value="guesser" class="w-full bg-red-500 text-white py-2 px-4 rounded">
Join as Guesser
</button>
{{end}}
</div>
{{if eq .Room.RedTeam.Mime ""}}
<div>
<button type="submit" name="role" value="mime" class="w-full bg-red-700 text-white py-2 px-4 rounded">
Join as Mime
</button>
</div>
{{end}}
</form>
</div>
{{end}}