replace the current line and don't show paid option when already paid

This commit is contained in:
Ruidy 2024-03-22 14:42:47 +01:00
parent 8db9e6ebb8
commit 057f9991e9
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
2 changed files with 20 additions and 8 deletions

View file

@ -1,7 +1,7 @@
package view package view
templ LineItem(item *ItemViewModel) { templ LineItem(item *ItemViewModel) {
<tr id="line-item"> <tr>
<td>{ item.Item }</td> <td>{ item.Item }</td>
<td>{ item.Quantity }</td> <td>{ item.Quantity }</td>
<td>{ item.Price }</td> <td>{ item.Price }</td>
@ -10,7 +10,9 @@ templ LineItem(item *ItemViewModel) {
<td>{ item.SubTotal }</td> <td>{ item.SubTotal }</td>
<td> <td>
<button class="secondary">Edit</button> <button class="secondary">Edit</button>
<button class="secondary" hx-post={ item.ItemUrl } hx-target="#line-item" hx-swap="outerHTML">Paid</button> if item.PaymentStatus != "Completed" {
<button class="secondary" hx-post={ item.ItemUrl } hx-target="closest tr" hx-swap="outerHTML">Paid</button>
}
</td> </td>
</tr> </tr>
} }

View file

@ -23,7 +23,7 @@ func LineItem(item *ItemViewModel) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent templ_7745c5c3_Var1 = templ.NopComponent
} }
ctx = templ.ClearChildren(ctx) ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr id=\"line-item\"><td>") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr><td>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -101,15 +101,25 @@ func LineItem(item *ItemViewModel) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td><button class=\"secondary\">Edit</button> <button class=\"secondary\" hx-post=\"") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td><button class=\"secondary\">Edit</button> ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(item.ItemUrl)) if item.PaymentStatus != "Completed" {
if templ_7745c5c3_Err != nil { _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<button class=\"secondary\" hx-post=\"")
return templ_7745c5c3_Err if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(item.ItemUrl))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"closest tr\" hx-swap=\"outerHTML\">Paid</button>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"#line-item\" hx-swap=\"outerHTML\">Paid</button></td></tr>") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td></tr>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }