package templates import ( "fmt" "mal/internal/database" "mal/internal/shared/ui" "math" ) templ Watchlist(entries []database.GetUserWatchListRow, layout string, currentStatus string, sortBy string, sortOrder string) { @Layout("mal - watchlist", true) {

Watchlist

Track what you're watching with less noise.

Export
All Watching On hold Plan to watch Dropped Completed
@ui.SortFilter(ui.SortFilterOptions{Sort: sortBy, Order: sortOrder, View: layout, Status: currentStatus}) if len(entries) == 0 { @ui.EmptyState("Nothing here yet") { if currentStatus == "all" { Your watchlist is empty. Search for anime to get started. } else { No anime in this category. } } } else { if layout == "grid" {
for _, entry := range entries {
{
{ entry.DisplayTitle() }
@ifHasProgress(entry)
}
} else { for _, entry := range entries { }
Title
{ { entry.DisplayTitle() } @ifHasProgress(entry)
} } } } templ ifHasProgress(entry database.GetUserWatchListRow) { if entry.CurrentEpisode.Valid && entry.CurrentEpisode.Int64 > 0 && entry.Status != "completed" {

Continue ep { fmt.Sprintf("%d", entry.CurrentEpisode.Int64) } if entry.CurrentTimeSeconds > 0 { { fmt.Sprintf(" ยท %s", formatProgressTime(entry.CurrentTimeSeconds)) } }

} } func watchURL(entry database.GetUserWatchListRow) string { return fmt.Sprintf("/anime/%d", entry.AnimeID) } func formatProgressTime(seconds float64) string { total := int(math.Round(seconds)) if total < 0 { total = 0 } minutes := total / 60 remainingSeconds := total % 60 return fmt.Sprintf("%02d:%02d", minutes, remainingSeconds) } func tabClass(active bool) string { base := "shrink-0 whitespace-nowrap bg-(--panel-soft) px-2 py-1 text-xs text-(--text-muted) no-underline hover:bg-(--surface-tab-hover) hover:text-(--text) hover:no-underline" if active { return "shrink-0 whitespace-nowrap bg-(--surface-tab-active) px-2 py-1 text-xs text-(--accent) no-underline hover:no-underline" } return base } func watchlistURL(view string, status string, sortBy string, sortOrder string) string { return fmt.Sprintf("/watchlist?view=%s&status=%s&sort=%s&order=%s", view, status, sortBy, sortOrder) }