import RastrilloApple import SwiftUI /// The same account menu composition as Docs, using the kit's rows, /// identity replacement confirmation and sign-out words. struct EquipoOficinaAccountMenu: View { let app: EquipoAppModel @ObservedObject var model: OficinaIDModel private var teams: [OficinaTeam] { guard let identity = model.identity else { return [] } return (model.store.teams(identity.id)?.teams ?? []).filter { $0.origin(for: "equipo") != nil } } var body: some View { Section { if let identity = model.identity { OficinaIdentityRow(identity: identity) } ForEach(teams) { team in Button { Task { await model.choose(team); await app.oficina.synchronize() } } label: { HStack { OficinaTeamRow(team: team) if app.session?.account.oficinaTeam == team.sqid { Image(systemName: "checkmark").accessibilityLabel(String(localized: "oficina.current_team", bundle: .module)) } } }.buttonStyle(.plain).disabled(model.busy) } if let error = app.oficina.error { Text(error).foregroundStyle(.secondary) } if let error = model.error { OficinaErrorLine(error) } Button(OficinaIDText.text("continue.another")) { model.useAnother() } Button(OficinaIDText.text("otherWays")) { app.otherWays() } Button(OficinaIDText.text("signOut", model.identity?.label ?? ""), role: .destructive) { Task { await app.signOut() } } } .task { await model.refreshTeams() } .oficinaReplaceConfirmation(model) } }