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
ActorActive string
ActorSold string
ActorPriceCompare string
UsePriceComparison bool
}
templ ItemPreview(d PreviewData) {
if d.Error != "" {
{ 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) {