goipam/web/templates/profile.templ

68 lines
1.9 KiB
Plaintext

package templates
import "git.jmbit.de/jmb/goipam/db"
templ ProfilePage(metaContent MetaContent, title string, user *db.User, err error) {
@wrapBase(metaContent, title, err) {
@profileMain(user)
}
}
templ profileMain(user *db.User) {
<div class="section is-medium">
<div class="container">
@ProfileStatic(user)
</div>
</div>
}
templ ProfileStatic(user *db.User) {
<div hx-target="this" hx-swap="outerHTML">
<div class="field">
<label class="label">Username</label> { user.Name }
</div>
<div class="field">
<label class="label">Display Name</label> { user.DisplayName }
</div>
<div class="field">
<label class="label">Email</label> { user.Email }
</div>
<button hx-get="/profile/edit.html" class="button is-primary">
Click To Edit
</button>
</div>
}
templ ProfileForm(user *db.User) {
<form hx-post="/profile/edit" hx-swap="outerHTML">
<div class="field">
<label class="label">Username</label> { user.Name }
</div>
<div class="field">
<label class="label">Display Name</label>
<input class="input" type="text" name="displayname" value={ user.DisplayName }/>
</div>
<div class="field">
<label class="label">Email Address</label>
<input class="input" type="email" name="email" value={ user.Email }/>
</div>
<button class="button is-primary">Submit</button>
<button class="button is-light" hx-get="/profile/static.html">Cancel</button>
</form>
}
templ PasswordForm(success bool, message string) {
<form hx-post="/profile/password.html" hx-swap="outerHTML">
<div class="field">
<label class="label">Password</label>
<input class="input" type="password" name="password" placeholder="************" required/>
</div>
<div class="field">
<label class="label">Confirm Password</label>
<input class="input" type="password" name="confirm" placeholder="************" required/>
</div>
<button class="button button-primary">Submit</button>
</form>
}