package templates import ( "fmt" "veola/internal/models" ) type SettingsData struct { Page Values map[string]string // CredentialStatus maps each secret settings key to a human-readable // status ("Saved in settings", "Set in config.toml", "Not set"). Secret // values are never rendered into the form itself. CredentialStatus map[string]string IsAdmin bool Users []models.User TestNtfyOK string TestApifyOK string TestEbayOK string EbayUsedToday int EbayDailyLimit int PasswordMsg string PasswordError string UserMsg string UserError string } // EbayLimitReached reports whether eBay polling is currently halted because // the daily call limit has been hit. func (d SettingsData) EbayLimitReached() bool { return d.EbayDailyLimit > 0 && d.EbayUsedToday >= d.EbayDailyLimit } // credStatus renders the "Saved in settings / Set in config.toml / Not set" // indicator for a secret field without ever printing the secret itself. templ credStatus(d SettingsData, key string) { if s := d.CredentialStatus[key]; s != "" {
Status: { s }
} } templ settingsBody(d SettingsData) {

Settings

Apify, eBay and Ntfy

@CSRFInput(d.CSRFToken)
@credStatus(d, "apify_api_key")
@credStatus(d, "ebay_client_id")
@credStatus(d, "ebay_client_secret")
eBay API calls today: if d.EbayDailyLimit > 0 { { fmt.Sprintf("%d / %d", d.EbayUsedToday, d.EbayDailyLimit) } } else { { fmt.Sprintf("%d (uncapped)", d.EbayUsedToday) } } if d.EbayLimitReached() { Limit reached. eBay polling halted until the next reset (midnight US Pacific). }
@credStatus(d, "ntfy_token")
if !d.IsAdmin {
Read-only for non-admin users.
} else {
}
if d.TestNtfyOK != "" {
{ d.TestNtfyOK }
} if d.TestApifyOK != "" {
{ d.TestApifyOK }
} if d.TestEbayOK != "" {
{ d.TestEbayOK }
}

Change Password

if d.PasswordError != "" {
{ d.PasswordError }
} if d.PasswordMsg != "" {
{ d.PasswordMsg }
}
@CSRFInput(d.CSRFToken)
if d.IsAdmin {

Users

if d.UserError != "" {
{ d.UserError }
} if d.UserMsg != "" {
{ d.UserMsg }
} for _, u := range d.Users { }
UsernameRoleCreated
{ u.Username } { string(u.Role) } { u.CreatedAt.Format("2006-01-02") }
}
} templ Settings(d SettingsData) { @Layout(d.Page, settingsBody(d)) }