mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-11 21:26:50 +00:00
129 lines
3.6 KiB
Text
129 lines
3.6 KiB
Text
package views
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/rjNemo/rentease/internal/domains/booking"
|
|
)
|
|
|
|
templ BookingById(booking *booking.Booking, items, platforms, paymentMethods []string) {
|
|
@BaseLayout() {
|
|
<div class="grid">
|
|
<hgroup>
|
|
<h1>Booking ID VFNI#{ fmt.Sprintf("%04s", strconv.Itoa(booking.Id)) } </h1>
|
|
<h2>Manage a booking </h2>
|
|
</hgroup>
|
|
<div>
|
|
<button class="outline">Create PDF</button>
|
|
</div>
|
|
</div>
|
|
<form method="POST">
|
|
<div class="grid">
|
|
<label for="name">
|
|
Customer full name
|
|
<input type="text" id="name" name="name" value={ booking.Name } required autofocus/>
|
|
</label>
|
|
<label for="phone_number">
|
|
Phone number
|
|
<input type="text" id="phone_number" name="phone_number" value={ booking.PhoneNumber }/>
|
|
</label>
|
|
</div>
|
|
<div class="grid">
|
|
<label for="customer_number">
|
|
Customer number
|
|
<input type="number" id="customer_number" name="customer_number" required value={ booking.CustomerNumber }/>
|
|
</label>
|
|
<label for="email">
|
|
Email
|
|
<input type="email" id="email" name="email" value={ booking.Email }/>
|
|
</label>
|
|
</div>
|
|
<div class="grid">
|
|
<label for="from">
|
|
From
|
|
<input type="date" id="from" name="from" value={ booking.From.Format("2006-01-02") }/>
|
|
</label>
|
|
<label for="to">
|
|
To
|
|
<input type="date" id="to" name="to" value={ booking.To.Format("2006-01-02") }/>
|
|
</label>
|
|
</div>
|
|
<div class="grid">
|
|
<label for="platform">
|
|
Platform
|
|
<select id="platform" name="platform">
|
|
<option value={ booking.Platform } selected>{ booking.Platform } </option>
|
|
for _, platform := range platforms {
|
|
<option value={ platform }>{ platform } </option>
|
|
}
|
|
</select>
|
|
</label>
|
|
<label for="platform_fees">
|
|
Fees
|
|
<input type="number" id="platform_fees" name="platform_fees" value={ booking.PlatformFees }/>
|
|
</label>
|
|
</div>
|
|
<button type="submit">Update</button>
|
|
</form>
|
|
<h3>Line Items </h3>
|
|
<figure>
|
|
<table role="grid">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">#</th>
|
|
<th scope="col">Item</th>
|
|
<th scope="col">Quantity</th>
|
|
<th scope="col">Price</th>
|
|
<th scope="col">Payment Method</th>
|
|
<th scope="col">Payment Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="line-items">
|
|
for _, item := range booking.Items {
|
|
<tr>
|
|
<th scope="row"></th>
|
|
<td>{ item.Item }</td>
|
|
<td>{ strconv.Itoa(item.Quantity) }</td>
|
|
<td>{ item.Price }</td>
|
|
<td>{ item.PaymentMethod }</td>
|
|
<td>{ item.PaymentStatus }</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</figure>
|
|
<details>
|
|
<summary role="button" class="secondary">Add line </summary>
|
|
<form hx-post={ fmt.Sprintf("/bookings/%d/items", booking.Id) } hx-target="#line-items" hx-swap="afterend">
|
|
<article>
|
|
<label for="new-line-item">
|
|
Item
|
|
<select name="item" id="new-line-item">
|
|
for _, item := range items {
|
|
<option value={ item }>{ item } </option>
|
|
}
|
|
</select>
|
|
</label>
|
|
<label for="new-line-quantity">
|
|
Quantity
|
|
<input type="number" name="quantity" id="new-line-quantity"/>
|
|
</label>
|
|
<label for="new-line-price">
|
|
Price
|
|
<input type="number" name="price" id="new-line-price"/>
|
|
</label>
|
|
<label for="new-line-method">
|
|
Payment Method
|
|
<select name="method" id="new-line-method">
|
|
for _, paymentMethod := range paymentMethods {
|
|
<option value={ paymentMethod }>{ paymentMethod } </option>
|
|
}
|
|
</select>
|
|
</label>
|
|
<button type="submit">Add</button>
|
|
</article>
|
|
</form>
|
|
</details>
|
|
}
|
|
}
|