Files
element-x-ios/ElementX/Sources/AppHooks/HealthChat/HealthChatAccountStatusSection.swift
T
Sedat Qaja 1edfb8057f fix(healthchat): refresh the account status whenever settings appears
The banner kept telling the user to complete a profile they had just
completed, and nothing was fetched until the screen was actually shown.
2026-10-19 09:17:37 +02:00

66 lines
2.4 KiB
Swift

//
// 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 {
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")
}
}