diff --git a/frontend/lib/models/am_user_registration_data.dart b/frontend/lib/models/am_user_registration_data.dart new file mode 100644 index 0000000..7a04ff2 --- /dev/null +++ b/frontend/lib/models/am_user_registration_data.dart @@ -0,0 +1,96 @@ +import 'dart:io'; + +class ChildminderId { + String firstName; + String lastName; + String address; + String postalCode; + String city; + String phone; + String email; + String password; + File? profilePicture; + bool photoConsent; + + ChildminderId({ + this.firstName = '', + this.lastName = '', + this.address = '', + this.postalCode = '', + this.city = '', + this.phone = '', + this.email = '', + this.password = '', + this.profilePicture, + this.photoConsent = false, + }); +} + +class ChildminderProfessional { + String dateOfBirth; + String birthCity; + String birthCountry; + String socialSecurityNumber; // NIR + String agreementNumber; + int maxChildren; + + ChildminderProfessional({ + this.dateOfBirth = '', + this.birthCity = '', + this.birthCountry = '', + this.socialSecurityNumber = '', + this.agreementNumber = '', + this.maxChildren = 1, + }); +} + +class ChildminderRegistrationData { + ChildminderId identity; + ChildminderProfessional professional; + String presentationMessage; + bool cguAccepted; + bool isPhotoRequired; + + ChildminderRegistrationData({ + ChildminderId? identityData, + ChildminderProfessional? professionalData, + this.presentationMessage = '', + this.cguAccepted = false, + this.isPhotoRequired = false, + }) : identity = identityData ?? ChildminderId(), + professional = professionalData ?? ChildminderProfessional(); + + void updateIdentity(ChildminderId data) { + identity = data; + } + + void updateProfessional(ChildminderProfessional data) { + professional = data; + } + + void updatePresentation(String message) { + presentationMessage = message; + } + + void acceptCGU() { + cguAccepted = true; + } + + bool get isComplete { + return identity.firstName.isNotEmpty && + identity.lastName.isNotEmpty && + identity.address.isNotEmpty && + identity.postalCode.isNotEmpty && + identity.city.isNotEmpty && + identity.phone.isNotEmpty && + identity.email.isNotEmpty && + identity.password.isNotEmpty && + professional.dateOfBirth.isNotEmpty && + professional.birthCity.isNotEmpty && + professional.birthCountry.isNotEmpty && + professional.socialSecurityNumber.isNotEmpty && + professional.agreementNumber.isNotEmpty && + cguAccepted && + (!isPhotoRequired || (identity.profilePicture != null && identity.photoConsent)); + } +} \ No newline at end of file diff --git a/frontend/lib/screens/auth/am/am_register_step1_sceen.dart b/frontend/lib/screens/auth/am/am_register_step1_sceen.dart index 0664857..85490b1 100644 --- a/frontend/lib/screens/auth/am/am_register_step1_sceen.dart +++ b/frontend/lib/screens/auth/am/am_register_step1_sceen.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:p_tits_pas/models/am_user_registration_data.dart'; import 'package:p_tits_pas/models/card_assets.dart'; -import 'package:p_tits_pas/models/parent_user_registration_data.dart'; import 'package:p_tits_pas/utils/data_generator.dart'; import 'package:p_tits_pas/widgets/FormFieldConfig.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -15,7 +15,7 @@ class AmRegisterStep1Screen extends StatefulWidget { class _AmRegisterStep1ScreenState extends State { final _formKey = GlobalKey(); - late UserRegistrationData _registrationData; + late ChildminderRegistrationData _registrationData; final _lastNameController = TextEditingController(); final _firstNameController = TextEditingController(); @@ -27,11 +27,15 @@ class _AmRegisterStep1ScreenState extends State { final _postalCodeController = TextEditingController(); final _cityController = TextEditingController(); + // File? _selectedImage; + // bool _photoConsent = false; + // final ImagePicker _picker = ImagePicker(); + @override void initState() { super.initState(); - _registrationData = UserRegistrationData(); + _registrationData = ChildminderRegistrationData(); _generateAndFillData(); } @@ -152,10 +156,10 @@ class _AmRegisterStep1ScreenState extends State { ], ]; - void _handleSubmit() { + void _handleSubmit() { if (_formKey.currentState?.validate() ?? false) { - _registrationData.updateParent1( - ParentData( + _registrationData.updateIdentity( + ChildminderId( firstName: _firstNameController.text, lastName: _lastNameController.text, address: _addressController.text, @@ -166,10 +170,12 @@ class _AmRegisterStep1ScreenState extends State { password: _passwordController.text, ), ); - Navigator.pushNamed(context, '/am-register/step2', arguments: _registrationData); + Navigator.pushNamed(context, '/am-register/step2', + arguments: _registrationData); } } + @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; @@ -189,7 +195,7 @@ class _AmRegisterStep1ScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - 'Étape 1/5', + 'Étape 1/4', style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54), ), const SizedBox(height: 10),