package view

templ PaymentLine(payment *PaymentViewModel) {
	<tr class="hover">
		<td></td>
		<td></td>
		<td>- { payment.Amount }</td>
		<td>
			{ payment.PaymentMethod }
			<span class="badge badge-outline badge-sm ml-2">{ payment.StripeStatus }</span>
		</td>
		<td></td>
		<td class="flex gap-2">
			<button
				class="btn btn-sm btn-outline"
				hx-get={ payment.PaymentUrl }
				hx-target="closest tr"
				hx-swap="outerHTML"
			>
				Edit
			</button>
		</td>
	</tr>
}

templ PaymentForm(payment *PaymentViewModel) {
	<tr class="hover">
		<form hx-put={ payment.PaymentUrl } id="edit-payment" hx-target="closest tr" hx-swap="outerHTML">
			<td></td>
			<td></td>
			<td>
				<input
					class="input input-bordered input-sm w-full"
					type="number"
					inputmode="decimal"
					step="0.01"
					value={ payment.Amount }
					name="amount"
					form="edit-payment"
				/>
			</td>
			<td>
				<input
					class="input input-bordered input-sm w-full"
					value={ payment.PaymentMethod }
					name="paymentMethod"
					form="edit-payment"
				/>
			</td>
			<td></td>
			<td>
				<button class="btn btn-sm btn-primary" type="submit" form="edit-payment">Save</button>
			</td>
		</form>
	</tr>
}

templ PaymentList(payments []*PaymentViewModel) {
	<tbody id="payment-lines">
		if len(payments) >0 {
			for _,payment := range payments {
				@PaymentLine(payment)
			}
		}
	</tbody>
}
