package xsample

import "strconv"
import (
	"github.com/emarifer/go-templ-project-structure/views/layout"
)

templ Counts(counter int) {
	<div id="xyzz">counter: { strconv.Itoa(counter) }</div>
}

templ Form(counter int) {
	// /show?team=x-men&member=wolverine
	// hx-get="/xsample/counterchange?type=min&counter"
	// /xsample/counterchange?type=min&counter=
	<div>
		<a
			class="btn btn-primary"
			type="submit"
			name="add"
			hx-target="#chgss"
			hx-swap="outerHTML"
			hx-get={ "/xsample/counter?type=plus&counter=" + strconv.Itoa(counter) }
		>+1</a>
	</div>
	<div>
		<a
			class="btn btn-danger"
			type="submit"
			name="min"
			hx-target="#chgss"
			hx-swap="outerHTML"
			hx-get={ "/xsample/counter?type=min&counter=" + strconv.Itoa(counter) }
		>-1</a>
	</div>
}

templ CssCtr() {
}

templ JsCtr() {
}

templ Page(counter int) {
	@layout.PlaygroundLayout("Coba counter", CssCtr(), JsCtr()) {
		<div id="chgss">
			@Counts(counter)
			@Form(counter)
		</div>
	}
}
