//
//  RoleClassificationSelectController.swift

//
//  Created by Leon on 2025/7/19.
//

import UIKit

/// Step 1
class RoleClassificationSelectController: RoleCreateBaseController<RoleClassificationSelect> {
    override class var shouldPresentThisVc: Bool {
        return true
    }

    lazy var viewModel: RoleCreateViewModel = RoleCreateViewModel()

    lazy var roleCharacterSetVc = RoleCharacterSetController()

    override func viewDidLoad() {
        super.viewDidLoad()

        setupViews()
        setupDats()
        setupEvents()
    }

    private func setupViews() {
    }

    private func setupDats() {
        
    }

    private func restoreEditInfo(aiInfo: AIUserModel?) {
        guard let info = aiInfo else { return }
        
        viewModel.requestParams.aiId = info.aiId
        
        container.restoreSelectRole(selectCode: info.roleCode)
        container.restoreSelectPerson(selectCode: info.characterCode)
        container.restoreSelectTag(selectCode: info.tagCode)
        
    }

    private func setupEvents() {
        container.bottomButton.addTarget(self, action: #selector(tapBottomButton), for: .touchUpInside)
        
        restoreEditInfo(aiInfo: viewModel.editAIInfo)
    }

    @objc private func tapBottomButton() {
        viewModel.requestParams.tagCode = container.selectTagCode
        viewModel.requestParams.roleCode = container.selectRoleCode
        viewModel.requestParams.characterCode = container.selectCharacterCode

        let vc = roleCharacterSetVc
        vc.viewModel = viewModel
        navigationController?.pushViewController(vc, animated: true)
    }
}
