// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.1020 package templates //lint:file-ignore SA4006 This context is only used if a nested component is present. import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import ( "fmt" "veola/internal/models" ) type ItemFormData struct { Page IsEdit bool Item models.Item Categories []string Errors []string } func itemSelected(have, want string) bool { return have == want } type marketplaceOpt struct { Value string Label string } func marketplaceOptions() []marketplaceOpt { return []marketplaceOpt{ {"ebay.com", "eBay (US)"}, {"ebay.co.uk", "eBay (UK)"}, {"ebay.de", "eBay (DE)"}, {"ebay.fr", "eBay (FR)"}, {"ebay.com.au", "eBay (AU)"}, {"ebay.ca", "eBay (CA)"}, {"yahoo.co.jp", "Yahoo Auctions JP"}, {"mercari.jp", "Mercari JP"}, } } func isKnownMarketplace(v string) bool { for _, o := range marketplaceOptions() { if o.Value == v { return true } } return false } func itemHasMarketplace(it models.Item, v string) bool { for _, m := range it.Marketplaces { if m == v { return true } } return false } // customMarketplacesCSV returns the comma-separated list of marketplaces on // the item that are NOT in the curated list, so the user can keep editing // unusual values without losing them. func customMarketplacesCSV(it models.Item) string { var custom []string for _, m := range it.Marketplaces { if !isKnownMarketplace(m) { custom = append(custom, m) } } return joinCSV(custom) } func joinCSV(vs []string) string { out := "" for i, v := range vs { if i > 0 { out += ", " } out += v } return out } func itemHasJapanMarketplace(it models.Item) bool { for _, m := range it.Marketplaces { if m == "yahoo.co.jp" || m == "mercari.jp" { return true } } return false } func newCategory(v string, known []string) string { if v == "" { return "" } for _, c := range known { if c == v { return "" } } return v } func itemFormBody(d ItemFormData) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var1 := templ.GetChildren(ctx) if templ_7745c5c3_Var1 == nil { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if d.IsEdit { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Edit ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(d.Item.Name) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/item_form.templ`, Line: 104, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "Add Item") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if len(d.Errors) > 0 { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } templ_7745c5c3_Err = itemFormInner(d).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } func itemFormInner(d ItemFormData) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var4 := templ.GetChildren(ctx) if templ_7745c5c3_Var4 == nil { templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = CSRFInput(d.CSRFToken).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
Each is searched independently; the lowest price across all wins. Cost scales with the number of queries.
At least one of search queries or URL is required.
Blank = alert on every new result.
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, m := range marketplaceOptions() { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "
Yahoo Auctions JP and Mercari JP search in Japanese. English queries return few or no results.
Pick one or more. Each is polled per cycle; one failure does not stop the others.
Drop results below this price. Filters out accessories and obvious junk.
Drop results whose title contains any of these. Case-insensitive substring match.
Advanced
Leave blank to use the configured default for the selected marketplace.
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if d.IsEdit { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, " Cancel") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, " Cancel Running preview… apify runs can take 30–60s.") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if !d.IsEdit { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } return nil }) } func formAction(d ItemFormData) templ.SafeURL { if d.IsEdit { return templ.SafeURL(fmt.Sprintf("/items/%d", d.Item.ID)) } return templ.SafeURL("/items/preview") } type pollOpt struct { Minutes int Label string } func pollOptions() []pollOpt { return []pollOpt{ {15, "15 min"}, {30, "30 min"}, {60, "1 hr"}, {120, "2 hr"}, {360, "6 hr"}, {720, "12 hr"}, {1440, "24 hr"}, } } func optFloat(p *float64) string { if p == nil { return "" } return fmt.Sprintf("%.2f", *p) } func ItemForm(d ItemFormData) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var28 := templ.GetChildren(ctx) if templ_7745c5c3_Var28 == nil { templ_7745c5c3_Var28 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = Layout(d.Page, itemFormBody(d)).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate