70 lines
2.4 KiB
Swift
70 lines
2.4 KiB
Swift
import SwiftUI
|
|
|
|
struct LeadOverviewStateView: View {
|
|
let error: LeadError?
|
|
let isLoading: Bool
|
|
let isSearching: Bool
|
|
let onRetry: () -> Void
|
|
let onReset: () -> Void
|
|
let onLogin: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 16) {
|
|
if isLoading {
|
|
ProgressView("Interessenten werden geladen …")
|
|
.padding(40)
|
|
} else if let error {
|
|
ContentUnavailableView {
|
|
Label("Interessenten nicht verfügbar", systemImage: "exclamationmark.icloud")
|
|
} description: {
|
|
Text(error.message)
|
|
} actions: {
|
|
if error == .unauthorized {
|
|
Button("Erneut anmelden", action: onLogin)
|
|
} else if error.allowsRetry {
|
|
Button("Erneut versuchen", action: onRetry)
|
|
}
|
|
if isSearching {
|
|
Button("Suche zurücksetzen", action: onReset)
|
|
}
|
|
}
|
|
} else {
|
|
ContentUnavailableView {
|
|
Label(isSearching ? "Keine Interessenten gefunden" : "Noch keine Interessenten",
|
|
systemImage: isSearching ? "magnifyingglass" : "person.2")
|
|
} description: {
|
|
Text(isSearching ? "Passe deine Suche oder den Filter an." : "Dir sind aktuell keine Interessenten zugeordnet.")
|
|
} actions: {
|
|
if isSearching { Button("Suche zurücksetzen", action: onReset) }
|
|
}
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
}
|
|
|
|
struct LeadErrorBanner: View {
|
|
let error: LeadError
|
|
let onRetry: () -> Void
|
|
let onLogin: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
Label {
|
|
Text(error.message)
|
|
} icon: {
|
|
Image(systemName: "exclamationmark.triangle")
|
|
}
|
|
if error == .unauthorized {
|
|
Button("Erneut anmelden", action: onLogin)
|
|
} else if error.allowsRetry {
|
|
Button("Übersicht aktualisieren", action: onRetry)
|
|
}
|
|
}
|
|
.font(.callout)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding()
|
|
.background(Color.orange.opacity(0.12), in: .rect(cornerRadius: 12))
|
|
}
|
|
}
|