package views import ( "nebula/layouts" "nebula/models" "strconv" "strings" "time" ) templ SettingsPage(data models.SettingsData, activeTab string) { @layouts.DashboardLayout("Settings - Sonr", layouts.WalletUser{Name: "Sonr Wallet", Address: "sonr1x9f...7k2m"}, "settings") { @settingsStyles()
Profile Devices OAuth Notifications Emails Phone Numbers Developer @ProfileTab(data.Profile) @DevicesTab(data.Devices) @OAuthTab(data.OAuth) @NotificationsTab(data.Notifications) @EmailsTab(data.Emails) @PhonesTab(data.Phones, data.SMSSettings) @DeveloperTab(data.Developer)
@AddEmailDialog() @AddPhoneDialog() @AddDeviceDialog() @GenerateKeyDialog() @AddWebhookDialog() @settingsScripts() } } templ ProfileTab(profile models.ProfileSettings) {
{ "@" }
Cancel Save Changes
} templ DevicesTab(devices []models.Device) {
Add Device
for _, device := range devices { @DeviceItem(device) }
} templ DeviceItem(device models.Device) {
Rename Remove
} func deviceIcon(deviceType string) string { switch deviceType { case "laptop": return "laptop" case "mobile": return "mobile" case "key": return "key" case "desktop": return "desktop" default: return "laptop" } } templ OAuthTab(oauth models.OAuthSettings) {
1 hour 24 hours 7 days 30 days Never expire
Always prompt for consent Only on first connection When new scopes requested
Cancel Save Changes
} templ AuthorizedClientCard(client models.AuthorizedClient) {
} templ NotificationsTab(prefs models.NotificationPrefs) {
Save Preferences
} templ NotificationRow(item models.NotificationItem) {
if item.Threshold > 0 {
USD
} else { }
} templ EmailsTab(emails []models.Email) {
Add Email
for _, email := range emails { @EmailItem(email) }
} templ EmailItem(email models.Email) {
if email.IsVerified { } else { }
if email.IsVerified { } else { }
Set as Primary Resend Verification Remove
} templ PhonesTab(phones []models.Phone, smsSettings models.SMSSettings) {
Add Phone
for _, phone := range phones { @PhoneItem(phone) }
} templ PhoneItem(phone models.Phone) {
Set as Primary Send Test SMS Remove
} templ DeveloperTab(dev models.DeveloperSettings) {
@OAuthAppConfigCard(dev.OAuthApp)
Cancel Save Changes
} templ APIKeyCard(key models.APIKey) {
if key.Environment == "live" { Active } else { Test Mode }
{ key.KeyPreview }
} templ WebhookCard(wh models.Webhook) {
Edit Send Test View Logs Delete
} templ OAuthAppConfigCard(config models.OAuthAppConfig) { OAuth Application
} templ AddEmailDialog() {
Cancel Send Verification
} templ AddPhoneDialog() {
Cancel Send Code
} templ AddDeviceDialog() {
Register Device or Use Security Key
Cancel
} templ GenerateKeyDialog() {
Test Mode Production Full Access Read Only Write Only
Cancel Generate Key
} templ AddWebhookDialog() {
Cancel Create Webhook
} func itoa(i int) string { return strconv.Itoa(i) } func formatDate(t time.Time) string { return t.Format("Jan 2, 2006") } func formatRelativeTime(t time.Time) string { diff := time.Since(t) if diff < time.Minute { return "Just now" } if diff < time.Hour { mins := int(diff.Minutes()) if mins == 1 { return "1 minute ago" } return strconv.Itoa(mins) + " minutes ago" } if diff < 24*time.Hour { hours := int(diff.Hours()) if hours == 1 { return "1 hour ago" } return strconv.Itoa(hours) + " hours ago" } days := int(diff.Hours() / 24) if days == 1 { return "1 day ago" } if days < 14 { return strconv.Itoa(days) + " days ago" } weeks := days / 7 if weeks == 1 { return "1 week ago" } return strconv.Itoa(weeks) + " weeks ago" } func formatEvents(events []string) string { if len(events) == 1 && events[0] == "*" { return "All" } return strings.Join(events, ", ") } templ settingsStyles() { } templ settingsScripts() { }