import 'package:auth/src/features/sign_up/models/sign_up_step_config.dart';
import 'package:auth/src/features/sign_up/presentation/sign_up_address_screen.dart';
import 'package:auth/src/features/sign_up/presentation/sign_up_password_screen.dart';
import 'package:auth/src/features/sign_up/presentation/sign_up_personal_screen.dart';
import 'package:auth/src/features/sign_up/presentation/state/sign_up_view_model.dart';
import 'package:design_system/design_system.dart';

List<SignUpStepConfig> signUpSteps() => [
  SignUpStepConfig(
    supertitle: 'Usuario y contacto',
    title: 'Crea tu usuario',
    subtitle: 'Con tu email y tu número podremos mantenerte siempre informado',
    bodyBuilder: (context, ref) {
      final theme = ref.watch(themePortProvider);
      final vm = ref.read(signUpViewModelProvider.notifier);
      final state = ref.watch(signUpViewModelProvider);

      return SignupPersonalScreen(
        firstNameTextFieldController: vm.firstNameController,
        lastNameTextFieldController: vm.lastNameController,
        documentNumberTextFieldController: vm.documentNumberController,
        phoneTextFieldController: vm.phoneController,
        emailTextFieldController: vm.emailController,
        documentTypeSelected: state.documentType.trim().isEmpty
            ? null
            : state.documentType,
        onDocumentTypeChanged: vm.setDocumentType,
        acceptTerms: state.acceptTerms,
        onAcceptTermsPressed: (v) => vm.setAcceptTerms(v ?? false),
        termsText: 'Acepto los términos y condiciones',
        theme: theme,
        firstNameLabel: 'Nombre',
        firstNameHint: 'Nombre',
        lastNameLabel: 'Apellido',
        lastNameHint: 'Apellido',
        documentTypeOptions: const ['DNI', 'NIE', 'Pasaporte'],
        documentTypeHint: 'Documento',
        documentNumberLabel: '',
        documentNumberHint: 'DNI/NIE/Pasaporte',
        phoneLabel: 'Teléfono móvil',
        phoneHint: 'Teléfono móvil',
        emailLabel: 'Correo electrónico',
        emailHint: 'Correo electrónico',
      );
    },
  ),
  SignUpStepConfig(
    supertitle: 'Datos personales',
    title: 'Identifícate',
    subtitle:
        'Nos aseguraremos de que la cuenta esté a nombre del adulto responsable',
    bodyBuilder: (context, ref) {
      final vm = ref.read(signUpViewModelProvider.notifier);
      final state = ref.watch(signUpViewModelProvider);

      return SignupAddressScreen(
        bornAtController: vm.bornAtController,

        relationshipSelected: state.relationship.trim().isEmpty
            ? null
            : state.relationship,
        onRelationshipChanged: vm.setRelationship,
        relationshipOptions: const ['father', 'mother', 'tutor'],
        relationshipHint: 'Selecciona una opción',
        relationshipLabel: '¿Qué familiar eres?',

        placeOfBirthController: vm.placeOfBirthController,
        birthCountryController: vm.birthCountryController,

        streetController: vm.addressStreetController,
        cityController: vm.addressCityController,
        provinceController: vm.addressProvinceController,
        stateController: vm.addressStateController,

        addressCountrySelected: state.address.country.trim().isEmpty
            ? null
            : state.address.country,
        onAddressCountryChanged: vm.setAddressCountry,
        addressCountryOptions: const ['Spain', 'France', 'Portugal'],
        addressCountryHint: 'País',
        addressCountryLabel: 'País (dirección)',

        postCodeController: vm.addressPostCodeController,

        birthDateLabel: 'Fecha de nacimiento',
        birthDateHint: 'DD/MM/AAAA',

        placeOfBirthLabel: 'Lugar de nacimiento',
        placeOfBirthHint: 'Ciudad de nacimiento',

        birthCountryLabel: 'País de nacimiento',
        birthCountryHint: 'País de nacimiento',

        streetLabel: 'Calle / Dirección',
        streetHint: 'Calle Gran Vía 30 6º',

        cityLabel: 'Ciudad',
        cityHint: 'Ciudad',

        provinceLabel: 'Provincia',
        provinceHint: 'Provincia',

        stateLabel: 'Comunidad / Estado',
        stateHint: 'Comunidad / Estado',

        postCodeLabel: 'Código postal',
        postCodeHint: '28013',
      );
    },
  ),

  SignUpStepConfig(
    supertitle: 'Domicilio',
    title: 'Tu dirección',
    subtitle:
        'Contraseña mínima de 8 caracteres, con una mayúscula, un número y un carácter especial',
    bodyBuilder: (context, ref) {
      final vm = ref.read(signUpViewModelProvider.notifier);
      final state = ref.watch(signUpViewModelProvider);

      return SignUpPasswordScreen(
        isPasswordVisible: state.isShowPassword,
        passwordTextFieldController: vm.passwordController,
        repeatPasswordTextFieldController: vm.repeatPasswordController,
      );
    },
  ),
];
