package templates
import (
"fmt"
"mal/internal/jikan"
"mal/internal/shared/ui"
"net/url"
)
templ Search(q string) {
@Layout("mal - search", true) {
if q != "" {
@ui.LoadingIndicator("Searching...")
} else {
@ui.EmptyState("Search for anime") {
Use the search bar above to find anime to add to your watchlist.
}
}
}
}
templ SearchResultsWrapper(query string, animes []jikan.Anime, nextPage int, hasNext bool) {
if len(animes) == 0 {
@ui.EmptyState("No results found.") {
Try a different search term.
}
} else {
@SearchItems(query, animes, nextPage, hasNext)
}
}
templ SearchItems(query string, animes []jikan.Anime, nextPage int, hasNext bool) {
@ui.InfiniteAnimeList(animes, hasNext, string(templ.URL(fmt.Sprintf("/api/search?q=%s&page=%d", url.QueryEscape(query), nextPage))), "results")
}