ptitspas-ynov/frontend/lib/utils/data_generator.dart
Hanim 01a7937004 feat: Implement multi-step registration for Childminder with data validation and summary display
- Added routes for registration steps 2, 3, and 4 in app_router.dart.
- Created AmRegisterStep2Screen for entering professional details including birth date, city, country, social security number, agreement number, and max children.
- Implemented validation for social security number and max children fields.
- Developed AmRegisterStep3Screen for entering a motivation message and accepting terms and conditions.
- Created AmRegisterStep4Screen to display a summary of the registration data for review before submission.
- Introduced SummaryCard widget for displaying user information in a structured format.
- Enhanced DataGenerator utility to provide realistic data for testing.
2025-08-18 16:37:27 +02:00

187 lines
8.7 KiB
Dart

import 'dart:math';
class DataGenerator {
static final Random _random = Random();
static final List<String> _firstNames = [
'Alice', 'Bob', 'Charlie', 'David', 'Eva', 'Félix', 'Gabrielle', 'Hugo', 'Inès', 'Jules',
'Léa', 'Manon', 'Nathan', 'Oscar', 'Pauline', 'Quentin', 'Raphaël', 'Sophie', 'Théo', 'Victoire'
];
static final List<String> _lastNames = [
'Martin', 'Bernard', 'Dubois', 'Thomas', 'Robert', 'Richard', 'Petit', 'Durand', 'Leroy', 'Moreau',
'Simon', 'Laurent', 'Lefebvre', 'Michel', 'Garcia', 'David', 'Bertrand', 'Roux', 'Vincent', 'Fournier'
];
static final List<String> _addressSuffixes = [
'Rue de la Paix', 'Boulevard des Rêves', 'Avenue du Soleil', 'Place des Étoiles', 'Chemin des Champs'
];
static final List<String> _motivationSnippets = [
'Nous cherchons une personne de confiance.',
'Nos horaires sont atypiques.',
'Notre enfant est plein de vie.',
'Nous souhaitons une garde à temps plein.',
'Une adaptation en douceur est primordiale pour nous.',
'Nous avons hâte de vous rencontrer.',
'La pédagogie Montessori nous intéresse.'
];
static final List<String> _frenchCities = [
'Paris', 'Lyon', 'Marseille', 'Toulouse', 'Nice', 'Nantes', 'Montpellier', 'Strasbourg',
'Bordeaux', 'Lille', 'Rennes', 'Reims', 'Saint-Étienne', 'Toulon', 'Le Havre', 'Grenoble',
'Dijon', 'Angers', 'Nîmes', 'Villeurbanne', 'Clermont-Ferrand', 'Le Mans', 'Aix-en-Provence',
'Brest', 'Tours', 'Amiens', 'Limoges', 'Annecy', 'Boulogne-Billancourt', 'Perpignan'
];
static final List<String> _countries = [
'France', 'Belgique', 'Suisse', 'Canada', 'Maroc', 'Algérie', 'Tunisie', 'Sénégal',
'Côte d\'Ivoire', 'Madagascar', 'Espagne', 'Italie', 'Portugal', 'Allemagne', 'Royaume-Uni'
];
static final List<String> _childminderPresentations = [
'Bonjour,\n\nJe suis assistante maternelle agréée depuis plusieurs années et je souhaite rejoindre votre plateforme. J\'ai de l\'expérience avec les enfants de tous âges et je privilégie un accompagnement bienveillant.\n\nCordialement',
'Madame, Monsieur,\n\nTitulaire d\'un agrément d\'assistante maternelle, je propose un accueil personnalisé dans un environnement sécurisé et stimulant. Je suis disponible pour discuter de vos besoins.\n\nBien à vous',
'Bonjour,\n\nAssistante maternelle passionnée, je propose un accueil de qualité dans ma maison adaptée aux enfants. J\'ai suivi plusieurs formations et je suis disponible à temps plein.\n\nÀ bientôt',
'Cher gestionnaire,\n\nJe suis une professionnelle expérimentée dans la garde d\'enfants. Mon domicile est aménagé pour accueillir les petits dans les meilleures conditions. Je serais ravie de faire partie de votre réseau.\n\nCordialement',
'Bonjour,\n\nDepuis 5 ans, j\'exerce comme assistante maternelle avec passion. Je propose des activités d\'éveil adaptées et un suivi personnalisé de chaque enfant. Mon agrément me permet d\'accueillir jusqu\'à 4 enfants.\n\nBien cordialement'
];
static String firstName() => _firstNames[_random.nextInt(_firstNames.length)];
static String lastName() => _lastNames[_random.nextInt(_lastNames.length)];
static String address() => "${_random.nextInt(100) + 1} ${_addressSuffixes[_random.nextInt(_addressSuffixes.length)]}";
static String postalCode() => "750${_random.nextInt(10)}${_random.nextInt(10)}";
static String city() => "Paris";
static String phone() => "06${_random.nextInt(10)}${_random.nextInt(10)}${_random.nextInt(10)}${_random.nextInt(10)}${_random.nextInt(10)}${_random.nextInt(10)}${_random.nextInt(10)}${_random.nextInt(10)}";
static String email(String firstName, String lastName) => "${firstName.toLowerCase()}.${lastName.toLowerCase()}@example.com";
static String password() => "password123"; // Simple pour le test
static String dob({bool isUnborn = false}) {
final now = DateTime.now();
if (isUnborn) {
final provisionalDate = now.add(Duration(days: _random.nextInt(180) + 30)); // Entre 1 et 7 mois dans le futur
return "${provisionalDate.day.toString().padLeft(2, '0')}/${provisionalDate.month.toString().padLeft(2, '0')}/${provisionalDate.year}";
} else {
final birthYear = now.year - _random.nextInt(3); // Enfants de 0 à 2 ans
final birthMonth = _random.nextInt(12) + 1;
final birthDay = _random.nextInt(28) + 1; // Simple, évite les pbs de jours/mois
return "${birthDay.toString().padLeft(2, '0')}/${birthMonth.toString().padLeft(2, '0')}/${birthYear}";
}
}
static bool boolean() => _random.nextBool();
static String motivation() {
int count = _random.nextInt(3) + 2; // 2 à 4 phrases
List<String> chosenSnippets = [];
while(chosenSnippets.length < count) {
String snippet = _motivationSnippets[_random.nextInt(_motivationSnippets.length)];
if (!chosenSnippets.contains(snippet)) {
chosenSnippets.add(snippet);
}
}
return chosenSnippets.join(' ');
}
static String birthDate() {
final now = DateTime.now();
final age = _random.nextInt(31) + 25; // Entre 25 et 55 ans
final birthYear = now.year - age;
final birthMonth = _random.nextInt(12) + 1;
final birthDay = _random.nextInt(28) + 1;
return "${birthDay.toString().padLeft(2, '0')}/${birthMonth.toString().padLeft(2, '0')}/${birthYear}";
}
/// Génère une ville de naissance française
static String birthCity() => _frenchCities[_random.nextInt(_frenchCities.length)];
/// Génère un pays de naissance
static String birthCountry() => _countries[_random.nextInt(_countries.length)];
/// Génère un numéro de sécurité sociale français (NIR)
static String socialSecurityNumber() {
// Format NIR français : 1 YYMM DD CCC KK
// 1 = sexe (1 homme, 2 femme)
final sex = _random.nextBool() ? '1' : '2';
// YY = année de naissance (2 derniers chiffres)
final currentYear = DateTime.now().year;
final birthYear = currentYear - (_random.nextInt(31) + 25); // 25-55 ans
final yy = (birthYear % 100).toString().padLeft(2, '0');
// MM = mois de naissance
final mm = (_random.nextInt(12) + 1).toString().padLeft(2, '0');
// DD = département de naissance (01-95)
final dd = (_random.nextInt(95) + 1).toString().padLeft(2, '0');
// CCC = numéro d'ordre (001-999)
final ccc = (_random.nextInt(999) + 1).toString().padLeft(3, '0');
// KK = clé de contrôle (simulation)
final kk = _random.nextInt(100).toString().padLeft(2, '0');
return '$sex$yy$mm$dd$ccc$kk';
}
/// Génère un numéro d'agrément pour assistante maternelle
static String agreementNumber() {
final year = DateTime.now().year;
final dept = _random.nextInt(95) + 1; // Département 01-95
final sequence = _random.nextInt(9999) + 1; // Numéro de séquence
return 'AM${dept.toString().padLeft(2, '0')}$year${sequence.toString().padLeft(4, '0')}';
}
/// Génère un nombre d'enfants maximum pour l'agrément (1-4)
static int maxChildren() => _random.nextInt(4) + 1;
/// Génère un message de présentation pour assistante maternelle
static String childminderPresentation() =>
_childminderPresentations[_random.nextInt(_childminderPresentations.length)];
/// Génère un âge d'enfant en mois (0-36 mois)
static int childAgeInMonths() => _random.nextInt(37);
/// Génère une durée d'expérience en années (1-15 ans)
static int experienceYears() => _random.nextInt(15) + 1;
/// Génère un tarif horaire (entre 3.50€ et 6.00€)
static double hourlyRate() {
final rate = 3.50 + (_random.nextDouble() * 2.50);
return double.parse(rate.toStringAsFixed(2));
}
/// Génère des disponibilités (jours de la semaine)
static List<String> availability() {
final days = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'];
final availableDays = <String>[];
// Au moins 3 jours de disponibilité
final minDays = 3;
final maxDays = days.length;
final numDays = _random.nextInt(maxDays - minDays + 1) + minDays;
final selectedIndices = <int>[];
while (selectedIndices.length < numDays) {
final index = _random.nextInt(days.length);
if (!selectedIndices.contains(index)) {
selectedIndices.add(index);
availableDays.add(days[index]);
}
}
return availableDays;
}
/// Génère des horaires (format "08h30-17h30")
static String workingHours() {
final startHours = [7, 8, 9];
final endHours = [16, 17, 18, 19];
final startHour = startHours[_random.nextInt(startHours.length)];
final endHour = endHours[_random.nextInt(endHours.length)];
final startMinutes = _random.nextBool() ? '00' : '30';
final endMinutes = _random.nextBool() ? '00' : '30';
return '${startHour}h$startMinutes-${endHour}h$endMinutes';
}
}