package templates
import (
"fmt"
"mal/integrations/jikan"
ui "mal/web/components"
"mal/web/shared/layout"
"net/url"
)
templ Search(q string) {
@layout.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, watchlistStatuses map[int]string, nextPage int, hasNext bool) {
if len(animes) == 0 {
@ui.EmptyState("No results found.") {
Try a different search term.
}
} else {
@SearchItems(query, animes, watchlistStatuses, nextPage, hasNext)
}
}
templ SearchItems(query string, animes []jikan.Anime, watchlistStatuses map[int]string, nextPage int, hasNext bool) {
@ui.InfiniteAnimeList(animes, watchlistStatuses, hasNext, string(templ.URL(fmt.Sprintf("/api/search?q=%s&page=%d", url.QueryEscape(query), nextPage))), "results")
}