| @@ -10,63 +10,62 @@ struct ScheduledReportsView: View { |
| 10 | 10 | var body: some View { |
| 11 | 11 | List { |
| 12 | 12 | Section("Overview") { |
| 13 | | VStack(alignment: .leading, spacing: 8) { |
| 14 | | if !FeatureAccessService.hasAccess(to: .automatedMonitoring) { |
| 15 | | Text("Scheduled reports require Pro.") |
| 16 | | .font(appDensity.font(.caption)) |
| 17 | | .foregroundStyle(.secondary) |
| 18 | | } |
| 13 | if !FeatureAccessService.hasAccess(to: .automatedMonitoring) { |
| 14 | Text("Scheduled reports require Pro.") |
| 15 | .font(appDensity.font(.caption)) |
| 16 | .foregroundStyle(.secondary) |
| 17 | } |
| 19 | 18 | |
| 20 | | Toggle("Scheduled Reports", isOn: Binding( |
| 21 | | get: { settings.isEnabled }, |
| 22 | | set: { newValue in |
| 23 | | settings.isEnabled = newValue |
| 24 | | saveSettings() |
| 25 | | } |
| 26 | | )) |
| 27 | | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 19 | Toggle("Scheduled Reports", isOn: Binding( |
| 20 | get: { settings.isEnabled }, |
| 21 | set: { newValue in |
| 22 | settings.isEnabled = newValue |
| 23 | saveSettings() |
| 24 | } |
| 25 | )) |
| 26 | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 28 | 27 | |
| 29 | | Picker("Cadence", selection: Binding( |
| 30 | | get: { settings.cadence }, |
| 31 | | set: { newValue in |
| 32 | | settings.cadence = newValue |
| 33 | | saveSettings() |
| 34 | | } |
| 35 | | )) { |
| 36 | | ForEach(ScheduledReportCadence.allCases) { cadence in |
| 37 | | Text(cadence.title).tag(cadence) |
| 38 | | } |
| 28 | Picker("Cadence", selection: Binding( |
| 29 | get: { settings.cadence }, |
| 30 | set: { newValue in |
| 31 | settings.cadence = newValue |
| 32 | saveSettings() |
| 39 | 33 | } |
| 34 | )) { |
| 35 | ForEach(ScheduledReportCadence.allCases) { cadence in |
| 36 | Text(cadence.title).tag(cadence) |
| 37 | } |
| 38 | } |
| 39 | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 40 | 40 | |
| 41 | | Picker("Format", selection: Binding( |
| 42 | | get: { settings.format }, |
| 43 | | set: { newValue in |
| 44 | | settings.format = newValue |
| 45 | | saveSettings() |
| 46 | | } |
| 47 | | )) { |
| 48 | | ForEach([DomainExportFormat.markdown, .pdf, .json]) { format in |
| 49 | | Text(format.title).tag(format) |
| 50 | | } |
| 41 | Picker("Format", selection: Binding( |
| 42 | get: { settings.format }, |
| 43 | set: { newValue in |
| 44 | settings.format = newValue |
| 45 | saveSettings() |
| 51 | 46 | } |
| 47 | )) { |
| 48 | ForEach([DomainExportFormat.markdown, .pdf, .json]) { format in |
| 49 | Text(format.title).tag(format) |
| 50 | } |
| 51 | } |
| 52 | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 52 | 53 | |
| 53 | | LabeledContent( |
| 54 | | "Last Generated", |
| 55 | | value: settings.lastGeneratedAt?.formatted(date: .abbreviated, time: .shortened) ?? "Never" |
| 56 | | ) |
| 54 | LabeledContent( |
| 55 | "Last Generated", |
| 56 | value: settings.lastGeneratedAt?.formatted(date: .abbreviated, time: .shortened) ?? "Never" |
| 57 | ) |
| 57 | 58 | |
| 58 | | if let statusMessage { |
| 59 | | Text(statusMessage) |
| 60 | | .font(appDensity.font(.caption)) |
| 61 | | .foregroundStyle(.secondary) |
| 62 | | } |
| 59 | if let statusMessage { |
| 60 | Text(statusMessage) |
| 61 | .font(appDensity.font(.caption)) |
| 62 | .foregroundStyle(.secondary) |
| 63 | } |
| 63 | 64 | |
| 64 | | Button(isGenerating ? "Generating…" : "Generate Now") { |
| 65 | | Task { await generateNow() } |
| 66 | | } |
| 67 | | .disabled(isGenerating) |
| 65 | Button(isGenerating ? "Generating…" : "Generate Now") { |
| 66 | Task { await generateNow() } |
| 68 | 67 | } |
| 69 | | .padding(.vertical, 4) |
| 68 | .disabled(isGenerating || !FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 70 | 69 | } |
| 71 | 70 | .listRowBackground(Color(.systemGray6).opacity(0.5)) |
| 72 | 71 | |