diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-04-27 23:55:31 +0200 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-04-27 23:55:31 +0200 |
commit | a55cfe8205d5cb2fb0948c173f23ad71d6614d13 (patch) | |
tree | 386a341b3bcc543ca8ac7bfe7ff944cac669fe25 /view/locks_list.templ | |
parent | df3068728abacfc98fa19f3dba62b35f65aea731 (diff) |
Rename everything to locker/lock
Diffstat (limited to 'view/locks_list.templ')
-rw-r--r-- | view/locks_list.templ | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/view/locks_list.templ b/view/locks_list.templ new file mode 100644 index 0000000..e940b88 --- /dev/null +++ b/view/locks_list.templ @@ -0,0 +1,51 @@ +package view
+
+import (
+ "stevenlr.com/locker/model"
+ "fmt"
+)
+
+templ lock(t model.Lock) {
+ <p class="lock-row">
+ <a href={ templ.URL(fmt.Sprint("/lock/", t.Id)) }>{ t.Name }</a>
+ -
+ <a
+ href="javascript:void(0);"
+ hx-delete={ fmt.Sprint("/lock/", t.Id) }
+ hx-target="closest .lock-row"
+ hx-confirm={ fmt.Sprint("Are you sure you want to delete lock \"", t.Name , "\"?") }
+ >Delete</a>
+ </p>
+}
+
+templ LockCreateForm(lockName string, err string) {
+ <form
+ hx-put="/lock"
+ hx-target="closest .locks-list"
+ hx-target-error="this"
+ >
+ <p>
+ <input type="text" name="lockName" value={ lockName } placeholder="Name" />
+ <input type="number" name="days" placeholder="Days" />
+ <input type="number" name="hours" placeholder="Hours" />
+ <button type="submit">Create</button>
+ </p>
+ if err != "" {
+ <p class="error">{ err }</p>
+ }
+ </form>
+}
+
+templ LocksList(locks []model.Lock, isSignedIn bool) {
+ <div class="locks-list">
+ if isSignedIn {
+ <h1>Locks</h1>
+ for _, t := range locks {
+ @lock(t)
+ }
+ <h4>Create lock</h4>
+ @LockCreateForm("", "")
+ }
+ </div>
+}
+
|