package templates import ( "fmt" "veola/internal/apify" ) type PreviewData struct { CSRFToken string Form FormValues Results []apify.UnifiedResult BestIndex int MinPrice float64 MaxPrice float64 StoreCount int Error string Empty bool Cached bool Currency string } // FormValues mirrors the Step 1 form so the confirm POST has every field. type FormValues struct { Name string SearchQuery string URL string Category string TargetPrice string MinPrice string ExcludeKeywords string NtfyTopic string NtfyPriority string PollIntervalMinutes string IncludeOutOfStock bool Marketplaces []string ListingType string Condition string Region string ActorActive string ActorSold string ActorPriceCompare string UsePriceComparison bool } templ ItemPreview(d PreviewData) { if d.Error != "" {
Could not run preview
{ d.Error }
} else if d.Empty {
No results found
Try a broader search query or a different marketplace.
} else {

{ fmt.Sprintf("Found %d results for '%s'", len(d.Results), d.Form.SearchQuery) } if d.Cached { cached }

@previewBest(d) if len(d.Results) > 1 {
Other results
if len(d.Results) > 6 {
{ fmt.Sprintf("and %d more", len(d.Results)-6) }
}
}
{ fmt.Sprintf("Prices range from %s to %s across %d stores", fmtNumber(d.MinPrice, d.Currency), fmtNumber(d.MaxPrice, d.Currency), d.StoreCount) }
} @confirmForm(d) } templ previewBest(d PreviewData) { if d.BestIndex >= 0 && d.BestIndex < len(d.Results) {
if d.Results[d.BestIndex].ImageURL != "" { } else {
}
Best Price
{ fmtNumber(d.Results[d.BestIndex].Price, d.Currency) }
{ d.Results[d.BestIndex].Title }
{ d.Results[d.BestIndex].Store }
if d.Results[d.BestIndex].MatchedQuery != "" {
via "{ d.Results[d.BestIndex].MatchedQuery }"
}
} } templ confirmForm(d PreviewData) {
@hidden("name", d.Form.Name) @hidden("search_query", d.Form.SearchQuery) @hidden("url", d.Form.URL) @hidden("category", d.Form.Category) @hidden("target_price", d.Form.TargetPrice) @hidden("min_price", d.Form.MinPrice) @hidden("exclude_keywords", d.Form.ExcludeKeywords) @hidden("ntfy_topic", d.Form.NtfyTopic) @hidden("ntfy_priority", d.Form.NtfyPriority) @hidden("poll_interval_minutes", d.Form.PollIntervalMinutes) @hiddenBool("include_out_of_stock", d.Form.IncludeOutOfStock) for _, m := range d.Form.Marketplaces { @hidden("marketplace", m) } @hidden("listing_type", d.Form.ListingType) @hidden("condition", d.Form.Condition) @hidden("region", d.Form.Region) @hidden("actor_active", d.Form.ActorActive) @hidden("actor_sold", d.Form.ActorSold) @hidden("actor_price_compare", d.Form.ActorPriceCompare) @hiddenBool("use_price_comparison", d.Form.UsePriceComparison) Back
} templ hidden(name, value string) { } templ hiddenBool(name string, value bool) { if value { } } func fmtNumber(p float64, currency string) string { if p == 0 { return "—" } return fmt.Sprintf("%s%.2f", currencySymbol(currency), p) }