rentease/internal/view/line_item.templ
2024-03-22 21:45:57 +01:00

34 lines
1.2 KiB
Text

package view
templ LineItem(item *ItemViewModel) {
<tr>
<td>{ item.Item }</td>
<td>{ item.Quantity }</td>
<td>{ item.Price }</td>
<td>{ item.PaymentMethod }</td>
<td>{ item.PaymentStatus }</td>
<td>{ item.SubTotal }</td>
<td>
<button class="secondary" hx-get={ item.ItemUrl } hx-target="closest tr" hx-swap="outerHTML">Edit</button>
if item.PaymentStatus != "Completed" {
<button class="secondary" hx-post={ item.ItemUrl } hx-target="closest tr" hx-swap="outerHTML">Paid</button>
}
</td>
</tr>
}
templ LineItemForm(item *ItemViewModel) {
<tr>
<form hx-put={ item.ItemUrl } id="edit-item" hx-target="closest tr" hx-swap="outerHTML">
<td><input value={ item.Item } name="item" form="edit-item"/></td>
<td><input value={ item.Quantity } name="quantity" form="edit-item"/></td>
<td><input value={ item.Price } name="price" form="edit-item"/></td>
<td><input value={ item.PaymentMethod } name="paymentMethod" form="edit-item"/></td>
<td><input value={ item.PaymentStatus } name="PaymentStatus" form="edit-item"/></td>
<td>{ item.SubTotal }</td>
<td>
<button class="secondary" type="submit" form="edit-item">Save</button>
</td>
</form>
</tr>
}