Timer token show & reset

This commit is contained in:
2024-04-16 23:08:59 +02:00
parent 4e715ab1e1
commit 13a85f4218
8 changed files with 225 additions and 76 deletions

View File

@ -5,6 +5,22 @@ import (
"stevenlr.com/timer/model"
)
templ TimerTokenForm(timer model.Timer) {
<p class="token-form">
<button
type="button"
hx-post={ fmt.Sprint("/timer/", timer.Id, "/resetToken") }
hx-target="closest .token-form"
hx-confirm="Are you sure you want to reset the token for this timer?"
>Reset token</button>
<button
type="button"
hx-get={ fmt.Sprint("/timer/", timer.Id, "/token") }
hx-swap="outerHTML"
>Show token</button>
</p>
}
templ TimerView(timer model.Timer) {
<div class="timer">
<h1>Timer "{ timer.Name }"</h1>
@ -38,6 +54,8 @@ templ TimerView(timer model.Timer) {
<button hx-target="closest .timer" hx-post={ fmt.Sprint("/timer/", timer.Id, "/addTime/4w") }>4 weeks</button>
</p>
}
<h3>API token</h3>
@TimerTokenForm(timer)
</div>
}