goipam/web/templates/profile.templ

68 lines
1.9 KiB
Plaintext
Raw Normal View History

2024-02-22 20:52:37 +01:00
package templates
import "git.jmbit.de/jmb/goipam/db"
templ ProfilePage(metaContent MetaContent, title string, user *db.User, err error) {
2024-02-22 20:52:37 +01:00
@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">
2024-02-23 11:22:28 +01:00
<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">
2024-02-22 20:52:37 +01:00
Click To Edit
</button>
</div>
}
templ ProfileForm(user *db.User) {
<form hx-post="/profile/edit" hx-swap="outerHTML">
2024-02-23 11:22:28 +01:00
<div class="field">
<label class="label">Username</label> { user.Name }
2024-02-22 20:52:37 +01:00
</div>
2024-02-23 11:22:28 +01:00
<div class="field">
<label class="label">Display Name</label>
<input class="input" type="text" name="displayname" value={ user.DisplayName }/>
2024-02-22 20:52:37 +01:00
</div>
2024-02-23 11:22:28 +01:00
<div class="field">
<label class="label">Email Address</label>
<input class="input" type="email" name="email" value={ user.Email }/>
2024-02-22 20:52:37 +01:00
</div>
2024-02-23 11:22:28 +01:00
<button class="button is-primary">Submit</button>
<button class="button is-light" hx-get="/profile/static.html">Cancel</button>
2024-02-22 20:52:37 +01:00
</form>
}
2024-02-23 11:22:28 +01:00
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>
2024-02-22 20:52:37 +01:00
}