// 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" "time" "veola/internal/db" "veola/internal/models" ) type DashboardData struct { Page Stats *db.DashboardStats RecentResults []ResultRow RecentAlerts []AlertRow // Budget surface, shown to every signed-in user (Apify calls cost money). ApifyToday int ApifyMonth int ApifyCostPerCall float64 MonthlyBudget float64 EbayToday int EbayLimit int } // ApifyMonthCost is the estimated month-to-date Apify spend in USD. func (d DashboardData) ApifyMonthCost() float64 { return float64(d.ApifyMonth) * d.ApifyCostPerCall } // BudgetPercent is month-to-date spend as a percent of the monthly budget, // clamped to [0,100]. Zero when no budget is set. func (d DashboardData) BudgetPercent() int { if d.MonthlyBudget <= 0 { return 0 } p := int(d.ApifyMonthCost() / d.MonthlyBudget * 100) if p < 0 { return 0 } if p > 100 { return 100 } return p } // BudgetOver reports whether estimated spend has exceeded the monthly budget. func (d DashboardData) BudgetOver() bool { return d.MonthlyBudget > 0 && d.ApifyMonthCost() > d.MonthlyBudget } type ResultRow struct { ItemID int64 ItemName string Title string Price *float64 Currency string Source string URL string ImageURL string FoundAt time.Time Alerted bool } type AlertRow struct { ItemName string Title string Price *float64 Currency string ImageURL string FoundAt time.Time } // DashboardBody is the self-refreshing inner block. It is both the initial // render target (inside Layout) and the response to /dashboard/refresh, so the // hx-swap="outerHTML" on its root div replaces it with a fresh copy of itself. // GetDashboardRefresh must render THIS, not Dashboard — rendering the full // Layout would inject a nested page (and a duplicate sidebar) into the div. func DashboardBody(d DashboardData) 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 } var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("Watching %d items · %d active", d.Stats.TotalItems, d.Stats.ActiveItems)) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/dashboard.templ`, Line: 82, Col: 113} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "