-
Notifications
You must be signed in to change notification settings - Fork 0
/
newExpense.templ
142 lines (140 loc) · 4.02 KB
/
newExpense.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package components
import (
"expense-tracker/types"
"fmt"
"github.com/google/uuid"
)
templ NewExpense(groupId string, isSubmit bool) {
<div class="flex flex-row justify-center items-center py-5 w-screen">
<form
class="flex flex-col justify-center items-center py-5 space-y-5 md:w-1/3 w-5/6m max-w-md"
hx-post={ string(templ.URL(fmt.Sprintf("/create_expense?g=%s", groupId))) }
hx-target-error="#feedback"
hx-indicator="#indicator"
>
<div class="text-2xl">
Add Expense
</div>
<div
class="w-full"
hx-get={ string(templ.URL(fmt.Sprintf("/groupSelect/%s", groupId))) }
hx-trigger="load"
hx-swap="outerHTML"
>
<select class="select select-bordered w-full text-base text-center"></select>
</div>
<div class="flex flex-row justify-start items-start w-full">
<div
class="w-full"
hx-get="/expense_types"
hx-trigger="load"
hx-swap="outerHTML"
>
<select class="select select-bordered w-3/5 text-base text-center"></select>
</div>
</div>
<div class="flex flex-row justify-start items-start w-full">
<label class="input input-bordered flex items-center w-full">
<input
type="text"
id="description"
name="description"
class="grow"
placeholder="Description"
/>
</label>
</div>
<div class="flex flex-row justify-start items-start w-full">
<select
class="select select-bordered w-1/3 text-base text-center"
id="currency"
name="currency"
>
<option selected>CAD</option>
<option>NTD</option>
<option>USD</option>
</select>
<label class="input input-bordered flex items-center w-full">
<input
type="number"
id="total"
name="total"
class="grow"
step="0.001"
placeholder="0.00"
/>
</label>
</div>
<div class="hidden">
<label style="display: inline-block;" class="w-2/3 h-12 border border-gray-400 rounded-full bg-base-100 hover:bg-base-300">
<input type="file" style="display: none;"/>
<div class="flex flex-row items-center justify-center h-full space-x-3">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
class="w-6 h-6 opacity-70"
fill="currentColor"
><path d="M4,4H7L9,2H15L17,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4M12,7A5,5 0 0,0 7,12A5,5 0 0,0 12,17A5,5 0 0,0 17,12A5,5 0 0,0 12,7M12,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9Z"></path></svg>
<p>Upload Receipt</p>
</div>
</label>
</div>
<div
id="splitRule"
class="w-2/3"
hx-get={ string(templ.URL(fmt.Sprintf("/split_rules?g=%s", groupId))) }
hx-trigger="load"
hx-swap="outerHTML"
>
@SplitRule(types.GroupMember{
UserID: uuid.NewString(),
Username: "user me",
}, []types.GroupMember{
{
UserID: uuid.NewString(),
Username: "user 1",
},
})
</div>
<button
id="submit"
type="submit"
class="btn btn-active btn-neutral btn-wide text-lg font-light"
disabled
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
class="w-6 h-6 opacity-70"
fill="currentColor"
><path d="M9,20.42L2.79,14.21L5.62,11.38L9,14.77L18.88,4.88L21.71,7.71L9,20.42Z"></path></svg>
OK
</button>
<div id="indicator" class="htmx-indicator">
<div class="flex justify-center items-center w-full">
<span class="loading loading-spinner loading-md"></span>
</div>
</div>
<div id="feedback" class={ templ.KV("hidden", !isSubmit) }>
<div class="animate-fade">
<div role="alert" class="alert alert-success">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 shrink-0 stroke-current"
fill="none"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
></path>
</svg>
<span>Your expense has been created!</span>
</div>
</div>
</div>
</form>
</div>
}