aboutsummaryrefslogblamecommitdiff
path: root/pkg/tpl/quote_admin.templ
blob: 80bafadae3d85375168e4cf0d0e8328e505f7fd3 (plain) (tree)



































                                                                                                              
package tpl

import (
	"sh.org.ru/pkg/model"
	"strconv"
)

templ Admin(quotes []model.Quote, count int) {
	@Layout(HeaderParams{}) {
		for _, q := range quotes {
			@QuoteAdmin(&q)
		}
		Всего { strconv.Itoa(count) } цитат.
	}
}

templ QuoteAdmin(quote *model.Quote) {
	<article>
		<header>#{ strconv.Itoa(int(quote.ID)) }</header>
		@templ.Raw(quote.Text())
		<footer>
			<form method="post" action="/admin/action">
				<input type="hidden" name="id" value={ strconv.Itoa(int(quote.ID)) }/>
				<div role="group">
					<input class="primary" type="submit" name="action" value="approve"/>
					<input class="secondary" type="submit" name="action" value="decline"/>
				</div>
			</form>
		</footer>
	</article>
}

type AdminForm struct {
	ID     int    `form:"id"`
	Action string `form:"action"`
}