import SwiftUI

/// Sheet that lets the user connect an additional BookStack server.
/// Reuses ConnectStepView — skips the language/welcome steps.
struct AddServerView: View {
    @Environment(\.dismiss) private var dismiss
    @State private var viewModel: OnboardingViewModel = {
        let vm = OnboardingViewModel()
        vm.isAddServerMode = true
        return vm
    }()

    var body: some View {
        NavigationStack {
            ConnectStepView(viewModel: viewModel)
                .navigationTitle(L("settings.servers.add"))
                .navigationBarTitleDisplayMode(.inline)
                .toolbar {
                    ToolbarItem(placement: .cancellationAction) {
                        Button(L("create.cancel")) { dismiss() }
                    }
                }
        }
        .onChange(of: viewModel.isAddComplete) { _, done in
            if done { dismiss() }
        }
    }
}
