feat: Update registration data model for Childminder and adjust related screen AM logic
This commit is contained in:
parent
14efccc711
commit
acda4244a9
96
frontend/lib/models/am_user_registration_data.dart
Normal file
96
frontend/lib/models/am_user_registration_data.dart
Normal file
@ -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));
|
||||
}
|
||||
}
|
||||
@ -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<AmRegisterStep1Screen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late UserRegistrationData _registrationData;
|
||||
late ChildminderRegistrationData _registrationData;
|
||||
|
||||
final _lastNameController = TextEditingController();
|
||||
final _firstNameController = TextEditingController();
|
||||
@ -27,11 +27,15 @@ class _AmRegisterStep1ScreenState extends State<AmRegisterStep1Screen> {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -154,8 +158,8 @@ class _AmRegisterStep1ScreenState extends State<AmRegisterStep1Screen> {
|
||||
|
||||
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<AmRegisterStep1Screen> {
|
||||
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<AmRegisterStep1Screen> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Étape 1/5',
|
||||
'Étape 1/4',
|
||||
style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user