57 lines
1.6 KiB
Plaintext
57 lines
1.6 KiB
Plaintext
package view
|
|
|
|
import (
|
|
"stevenlr.com/locker/model"
|
|
)
|
|
|
|
templ LoginFormError(currentUser *model.User, err string) {
|
|
if currentUser == nil {
|
|
<div class="login-form">
|
|
<form
|
|
hx-post="/login"
|
|
hx-target-error="closest .login-form"
|
|
class="
|
|
w-80
|
|
mx-auto
|
|
flex flex-col
|
|
gap-4
|
|
"
|
|
>
|
|
@TextField("user", "User name")
|
|
@PasswordField("password", "Password")
|
|
@Button("submit", "Sign in", templ.Attributes{})
|
|
if err != "" {
|
|
<span class="text-red-400">{ err }</span>
|
|
}
|
|
</form>
|
|
</div>
|
|
} else {
|
|
<div class="
|
|
flex flex-row items-baseline justify-start
|
|
"
|
|
>
|
|
<h1
|
|
class="
|
|
grow
|
|
text-slate-300 text-4xl font-semibold
|
|
"
|
|
>Prout prout</h1>
|
|
<div
|
|
class="
|
|
flex flex-row justify-end items-center gap-4
|
|
"
|
|
>
|
|
<p>Signed in as <b>{ currentUser.Name }</b></p>
|
|
@SecondaryButton("button", "Sign out", templ.Attributes{
|
|
"hx-post": "/logout",
|
|
"hx-refresh": true,
|
|
})
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
templ LoginForm(currentUser *model.User) {
|
|
@LoginFormError(currentUser, "")
|
|
}
|