import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:go_router/go_router.dart';

import '../../models/user_registration_data.dart';
import '../../widgets/personal_info_form_screen.dart';
import '../../services/reprise_session.dart';
import '../../models/card_assets.dart';

class ParentRegisterStep1Screen extends StatelessWidget {
  const ParentRegisterStep1Screen({super.key});

  @override
  Widget build(BuildContext context) {
    final registrationData = Provider.of<UserRegistrationData>(context, listen: false);
    final parent1 = registrationData.parent1;
    
    final initialData = PersonalInfoData(
      firstName: parent1.firstName,
      lastName: parent1.lastName,
      phone: parent1.phone,
      email: parent1.email,
      address: parent1.address,
      postalCode: parent1.postalCode,
      city: parent1.city,
    );

    return PersonalInfoFormScreen(
      stepText: 'Étape 1/5',
      title: 'Informations du Parent Principal',
      cardColor: CardColorHorizontal.peach,
      initialData: initialData,
      previousRoute: RepriseSession.isActive ? '/login' : '/register-choice',
      onSubmit: (data, {hasSecondPerson, sameAddress}) {
        registrationData.updateParent1(ParentData(
          firstName: data.firstName,
          lastName: data.lastName,
          phone: data.phone,
          email: data.email,
          address: data.address,
          postalCode: data.postalCode,
          city: data.city,
          password: '',
        ));
        context.go('/parent-register-step2');
      },
    );
  }
}
