//
//  DebugLandView.swift
//  AlloVoisinsSwiftUI
//
//  Created by Victor on 15/01/2025.
//

import SwiftUI

enum DebugEnvironment {
    case allo1
    case allo2
    case preprod
    case hotfix
    case prod
}

struct DebugLandView: View {
    @State var currentEnv: PickerOption = .init(text: "Preprod")
    @State var userId: String = ""

    var pickerOptions: [PickerOption] {
        [
            PickerOption(text: "Allo1"),
            PickerOption(text: "Allo2"),
            PickerOption(text: "Allo3"),
            PickerOption(text: "Allo4"),
            PickerOption(text: "Allo5"),
            PickerOption(text: "Allo6"),
            PickerOption(text: "Allo7"),
            PickerOption(text: "Allo8"),
            PickerOption(text: "Allo9"),
            PickerOption(text: "Allo10"),
            PickerOption(text: "Preprod"),
            PickerOption(text: "Hotfix"),
            PickerOption(text: "Prod"),
        ]
    }

    var body: some View {
        ScrollView {
            VStack(spacing: 16) {
                CurrentDebugUser()

                VStack {
                    SQText("Environnement :")
                        .sqFont(.semiBold)
                    SQText("Prod")
                        .sqFont(.bold)
                        .padding(.vertical, 4)
                        .padding(.horizontal, 8)
                        .background {
                            RoundedRectangle(cornerRadius: 8)
                                .fill(Color.sqRed())
                        }
                    SQButton("Changer d'environnement") {
                        
                    }
                }
                .frame(maxWidth: .infinity)
                .padding()
                .background {
                    RoundedRectangle(cornerRadius: 10)
                        .fill(Color.sqNeutral(10))
                }
                .padding(.horizontal)

                VStack(alignment: .leading, spacing: 8) {
                    SQText("User ID :")
                        .sqFont(.semiBold)
                    HStack(spacing: 8) {
                        VStack {
                            SQTextField("Visiter le profil :", text: $userId)
                                .sqPlaceholder("UserID")
                            SQButton("Visiter le profil") {

                            }
                        }
                        VStack {
                            SQTextField("Se connecter sur :",  text: $userId)
                                .sqPlaceholder("UserID")
                                .keyboardType(.numberPad)
                            SQButton("Se connecter") {

                            }
                        }
                    }
                }
                .padding()
                .background {
                    RoundedRectangle(cornerRadius: 10)
                        .fill(Color.sqNeutral(10))
                }
                .padding(.horizontal)

                VStack {
                    LazyHGrid(rows: [
                        GridItem.init(),
                        GridItem.init()
                    ]) {
                            DebugActionView(title: "")
                            DebugActionView(title: "")
                            DebugActionView(title: "")
                            DebugActionView(title: "")
                        }
                }
            }
        }
        .toolbar {
            ToolbarItem(placement: .principal) {
                SQText("🦄 Debug Land 🦄")
                    .sqFont(.bold)
            }

            ToolbarItem(placement: .primaryAction) {
                Button {} label: {
                    SQIcon(.user_group)
                }
            }
            ToolbarItem(placement: .topBarTrailing) {
                Button {} label: {
                    SQIcon(.ballot_check)
                }
            }
        }
    }
}

#Preview {
    NavigationStack {
        DebugLandView()
    }
}
