2024-05-27 21:10:37 +07:00
|
|
|
package put
|
|
|
|
|
|
|
|
import "github.com/tigorlazuardi/redmage/views"
|
|
|
|
import "github.com/tigorlazuardi/redmage/views/components"
|
|
|
|
|
|
|
|
type Data struct {
|
|
|
|
Title string
|
2024-05-28 00:30:29 +07:00
|
|
|
EditMode bool
|
|
|
|
PostAction string
|
2024-05-27 21:10:37 +07:00
|
|
|
NameInput NameInputData
|
|
|
|
TypeInput TypeInputData
|
|
|
|
ScheduleInput ScheduleInputData
|
|
|
|
CountbackInput CountbackInputData
|
|
|
|
}
|
|
|
|
|
|
|
|
templ View(c *views.Context, data Data) {
|
|
|
|
@components.Doctype() {
|
|
|
|
@components.Head(c, components.HeadTitle(data.Title))
|
|
|
|
@components.Body(c) {
|
|
|
|
@Content(c, data)
|
|
|
|
@components.NotificationContainer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
templ Content(c *views.Context, data Data) {
|
|
|
|
<main class="prose min-w-full">
|
|
|
|
@components.Container() {
|
2024-05-28 00:30:29 +07:00
|
|
|
<h1>{ data.Title }</h1>
|
2024-05-27 21:10:37 +07:00
|
|
|
<div class="divider"></div>
|
|
|
|
<form
|
2024-05-28 00:30:29 +07:00
|
|
|
action={ templ.SafeURL(data.PostAction) }
|
2024-05-27 21:10:37 +07:00
|
|
|
method="POST"
|
2024-05-28 00:30:29 +07:00
|
|
|
hx-post={ data.PostAction }
|
2024-05-27 21:10:37 +07:00
|
|
|
hx-target-error={ components.NotificationContainerID }
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="grid grid-cols-1 sm:grid-cols-2 gap-4"
|
|
|
|
>
|
2024-05-28 00:30:29 +07:00
|
|
|
if !data.EditMode {
|
|
|
|
@NameInput(data.NameInput)
|
|
|
|
}
|
|
|
|
if !data.EditMode {
|
|
|
|
@TypeInput(data.TypeInput)
|
|
|
|
}
|
2024-05-27 21:10:37 +07:00
|
|
|
<div class="sm:col-span-2">
|
|
|
|
@ScheduleInput(data.ScheduleInput)
|
|
|
|
</div>
|
|
|
|
<div class="sm:col-span-2">
|
|
|
|
@CountbackInput(data.CountbackInput)
|
|
|
|
</div>
|
2024-05-28 00:30:29 +07:00
|
|
|
if !data.EditMode {
|
|
|
|
<div class="sm:col-span-2">
|
|
|
|
<div class="max-w-xs mx-auto">
|
|
|
|
@FetchCheckbox()
|
|
|
|
</div>
|
2024-05-27 21:10:37 +07:00
|
|
|
</div>
|
2024-05-28 00:30:29 +07:00
|
|
|
}
|
2024-05-27 21:10:37 +07:00
|
|
|
</div>
|
2024-05-28 00:30:29 +07:00
|
|
|
<button type="submit" class="block btn btn-primary mx-auto w-full max-w-xs mt-8 text-primary-content">
|
|
|
|
if data.EditMode {
|
|
|
|
Save
|
|
|
|
} else {
|
|
|
|
Add
|
|
|
|
}
|
|
|
|
</button>
|
2024-05-27 21:10:37 +07:00
|
|
|
</form>
|
|
|
|
}
|
|
|
|
</main>
|
|
|
|
}
|