mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
28 lines
933 B
Text
28 lines
933 B
Text
package view
|
|
|
|
type LoginFormViewModel struct {
|
|
Email string
|
|
Password string
|
|
Errors map[string]string
|
|
}
|
|
|
|
func isFormError(data map[string]string, key string) bool {
|
|
_, ok := data[key]
|
|
return ok
|
|
}
|
|
|
|
templ LoginForm(lfvm LoginFormViewModel) {
|
|
<form hx-post="/">
|
|
<input type="email" name="email" value={ lfvm.Email } placeholder="john@email.com" aria-label="email" if isFormError(lfvm.Errors, "credentials") {
|
|
aria-invalid="true"
|
|
} autocomplete="email" autofocus required=""/>
|
|
<input type="password" name="password" value={ lfvm.Password } placeholder="p4Ssw0rD" aria-label="password" if isFormError(lfvm.Errors, "credentials") {
|
|
aria-invalid="true"
|
|
} autocomplete="password" required=""/>
|
|
if msg, ok := lfvm.Errors["credentials"]; ok {
|
|
<small>Authentication error: { msg }</small>
|
|
}
|
|
<button type="submit">Log in</button>
|
|
<small>Registration is disabled. Please ask an admin to activate it.</small>
|
|
</form>
|
|
}
|