// // Copyright 2026 Novaloop AG // // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. // Please see LICENSE files in the repository root for full details. // import Compound import SwiftUI /// The account status advertised in the app's settings. Renders nothing while loading, /// for approved accounts with a complete profile, and when the status can't be read. /// /// Neither banner is dismissible — both resolve server-side. struct HealthChatAccountStatusSection: View { // Owned by the hook, not the view: the settings screen rebuilds this section on // every body pass, and a view-owned loader would fire a request each time. private let loader: HealthChatAccountStatusLoader private let completeProfileAction: () -> Void init(loader: HealthChatAccountStatusLoader, completeProfileAction: @escaping () -> Void = { }) { self.loader = loader self.completeProfileAction = completeProfileAction } var body: some View { switch loader.status { case .unknown, .ok: EmptyView() case .pendingApproval: Section { ListRow(label: .default(title: HealthChatL10n.screenMemberDirectoryPendingTitle, description: HealthChatL10n.screenMemberDirectoryPendingApproval, icon: \.time), kind: .label) } case .incompleteProfile(let message): Section { ListRow(label: .default(title: HealthChatL10n.commonProfileIncomplete, description: message, icon: \.info), kind: .label) ListRow(label: .action(title: HealthChatL10n.actionCompleteProfile, icon: \.userProfile), kind: .button(action: completeProfileAction)) } } } } // MARK: - Previews struct HealthChatAccountStatusSection_Previews: PreviewProvider, TestablePreview { static var previews: some View { Form { HealthChatAccountStatusSection(loader: .init(status: .pendingApproval)) } .compoundList() .previewDisplayName("Pending approval") Form { HealthChatAccountStatusSection(loader: .init(status: .incompleteProfile(message: "Bitte vervollständigen Sie Ihr Profil, bevor Sie die Benutzersuche verwenden"))) } .compoundList() .previewDisplayName("Incomplete profile") } }