mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-10 20:56:50 +00:00
render new item list on modal submit
This commit is contained in:
parent
00f3f856dd
commit
1efb11c300
6 changed files with 76 additions and 2 deletions
10
internal/service/booking/payment.go
Normal file
10
internal/service/booking/payment.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package booking
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Payment struct {
|
||||
gorm.Model
|
||||
BookingID int
|
||||
Amount float64
|
||||
PaymentMethod string
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ templ PaymentModal(paymentUrl string) {
|
|||
class="py-4 space-y-4"
|
||||
hx-post={ paymentUrl }
|
||||
hx-target="#line-items"
|
||||
hx-swap="innerHTML"
|
||||
hx-swap="outerHTML"
|
||||
hx-on::after-request="if(event.detail.successful) payment_modal.close()"
|
||||
>
|
||||
<div class="form-control w-full">
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ func PaymentModal(paymentUrl string) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "\" hx-target=\"#line-items\" hx-swap=\"innerHTML\" hx-on::after-request=\"if(event.detail.successful) payment_modal.close()\"><div class=\"form-control w-full\"><label class=\"label\"><span class=\"label-text\">Amount</span></label> <input type=\"number\" step=\"0.01\" name=\"amount\" class=\"input input-bordered w-full\" required autofocus></div><div class=\"form-control w-full\"><label class=\"label\"><span class=\"label-text\">Payment Method</span></label> <select name=\"paymentMethod\" class=\"select select-bordered w-full\" required><option value=\"\">Select payment method</option> <option value=\"Cash\">Cash</option> <option value=\"Card\">Card</option> <option value=\"Cheque\">Cheque</option> <option value=\"Transfer\">Bank Transfer</option></select></div><button type=\"submit\" class=\"btn btn-primary\">Add Payment </button></form></div></dialog>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "\" hx-target=\"#line-items\" hx-swap=\"outerHTML\" hx-on::after-request=\"if(event.detail.successful) payment_modal.close()\"><div class=\"form-control w-full\"><label class=\"label\"><span class=\"label-text\">Amount</span></label> <input type=\"number\" step=\"0.01\" name=\"amount\" class=\"input input-bordered w-full\" required autofocus></div><div class=\"form-control w-full\"><label class=\"label\"><span class=\"label-text\">Payment Method</span></label> <select name=\"paymentMethod\" class=\"select select-bordered w-full\" required><option value=\"\">Select payment method</option> <option value=\"Cash\">Cash</option> <option value=\"Card\">Card</option> <option value=\"Cheque\">Cheque</option> <option value=\"Transfer\">Bank Transfer</option></select></div><button type=\"submit\" class=\"btn btn-primary\">Add Payment </button></form></div></dialog>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
|||
9
internal/view/item_list.templ
Normal file
9
internal/view/item_list.templ
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package view
|
||||
|
||||
templ ItemList(itemList ItemListViewModel) {
|
||||
<tbody id="line-items">
|
||||
for _, item := range itemList.Items {
|
||||
@LineItem(&item)
|
||||
}
|
||||
</tbody>
|
||||
}
|
||||
50
internal/view/item_list_templ.go
Normal file
50
internal/view/item_list_templ.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.819
|
||||
package view
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func ItemList(itemList ItemListViewModel) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<tbody id=\"line-items\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, item := range itemList.Items {
|
||||
templ_7745c5c3_Err = LineItem(&item).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</tbody>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
5
internal/view/item_list_viewmodel.go
Normal file
5
internal/view/item_list_viewmodel.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package view
|
||||
|
||||
type ItemListViewModel struct {
|
||||
Items []ItemViewModel
|
||||
}
|
||||
Loading…
Reference in a new issue