79 lines
2.3 KiB
Plaintext
Raw Normal View History

2024-07-14 12:57:40 +02:00
package pages
import (
"git.ekzyis.com/ekzyis/delphi.market/server/router/pages/components"
"git.ekzyis.com/ekzyis/delphi.market/types"
"strconv"
"time"
)
templ User(user *types.User) {
<html>
@components.Head()
<body class="container">
@components.Nav()
<div id="content" class="flex flex-col">
@components.Figlet("random", "user")
<div
2024-09-11 11:17:28 +02:00
class="grid grid-cols-[1fr_3fr] gap-4 my-3 mx-auto"
2024-07-14 12:57:40 +02:00
hx-target="#content"
hx-swap="outerHTML"
hx-select="#content"
hx-push-url="true"
hx-select-oob="#nav"
>
<div class="font-bold">id</div>
<div>{ strconv.Itoa(user.Id) }</div>
<div class="font-bold">name</div>
2024-09-11 11:17:28 +02:00
<div class="flex">
<span id="name">{ user.Name }</span>
<form
class="hidden flex mb-0"
hx-put="/user"
hx-push-url="false"
hx-target="#name"
hx-select="#name"
>
<input
name="name"
type="text"
value={ user.Name }
required
maxlength="16"
class="font-mono w-[160px]"
/>
<button class="ms-1 px-1" type="submit">save</button>
</form>
<button id="cancel" class="hidden flex text-muted hover:text-reset text-xs items-center ms-1">cancel</button>
<button id="edit" class="flex text-muted hover:text-reset text-xs items-center ms-1" hx-preserve>edit</button>
</div>
2024-07-14 12:57:40 +02:00
<div class="font-bold">joined</div>
<div>{ user.CreatedAt.Format(time.DateOnly) }</div>
<div class="font-bold">sats</div>
2024-09-09 00:35:01 +02:00
<!-- TODO: implement withdrawal of sats -->
2024-09-11 11:17:28 +02:00
<div class="flex">
<span>{ strconv.Itoa(int(user.Msats) / 1000) }</span>
<button class="flex text-muted hover:text-reset text-xs items-center ms-3">withdraw</button>
</div>
2024-09-09 00:35:01 +02:00
<!-- TODO: add WebLN and NWC for send+recv -->
2024-07-14 12:57:40 +02:00
<button hx-post="/logout" class="col-span-2">logout</button>
</div>
2024-09-11 11:17:28 +02:00
<script>
function toggleForm () {
htmx.toggleClass("#name", "hidden")
htmx.toggleClass("#name+form", "hidden")
htmx.toggleClass("#cancel", "hidden")
htmx.toggleClass("#edit", "hidden")
$("#name+form>input").focus()
}
htmx.on("#edit", "click", toggleForm)
htmx.on("#cancel", "click", toggleForm)
htmx.on("form", "htmx:afterRequest", toggleForm)
</script>
2024-07-14 12:57:40 +02:00
</div>
@components.Footer()
</body>
</html>
}