feat(#112): reprise après refus via lien e-mail (/reprise?token=)
Branche le flux front : chargement du dossier, session reprise, wizards parent/AM préremplis et resoumission via reprise-resoumettre. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import 'package:p_tits_pas/models/am_registration_data.dart';
|
||||
import 'package:p_tits_pas/models/reprise_dossier.dart';
|
||||
import 'package:p_tits_pas/models/user_registration_data.dart';
|
||||
import 'package:p_tits_pas/services/api/api_config.dart';
|
||||
|
||||
/// Contexte reprise après refus (token e-mail ou identify). Ticket #112.
|
||||
class RepriseSession {
|
||||
RepriseSession._();
|
||||
|
||||
static String? _token;
|
||||
static String? _role;
|
||||
static String? _photoUrl;
|
||||
|
||||
static bool get isActive =>
|
||||
_token != null && _token!.trim().isNotEmpty;
|
||||
|
||||
static String? get token => _token;
|
||||
|
||||
static bool get isParent => _role == 'parent';
|
||||
|
||||
static bool get isAm => _role == 'assistante_maternelle';
|
||||
|
||||
static String? get photoUrl => _photoUrl;
|
||||
|
||||
static void start({
|
||||
required String token,
|
||||
required RepriseDossier dossier,
|
||||
}) {
|
||||
_token = token.trim();
|
||||
_role = dossier.role;
|
||||
_photoUrl = dossier.photoUrl?.trim().isNotEmpty == true
|
||||
? ApiConfig.absoluteMediaUrl(dossier.photoUrl)
|
||||
: null;
|
||||
}
|
||||
|
||||
static void clear() {
|
||||
_token = null;
|
||||
_role = null;
|
||||
_photoUrl = null;
|
||||
}
|
||||
|
||||
static void applyToParent(UserRegistrationData data, RepriseDossier dossier) {
|
||||
data.resetForReprise(
|
||||
firstName: dossier.prenom ?? '',
|
||||
lastName: dossier.nom ?? '',
|
||||
phone: dossier.telephone ?? '',
|
||||
email: dossier.email,
|
||||
address: dossier.adresse ?? '',
|
||||
postalCode: dossier.codePostal ?? '',
|
||||
city: dossier.ville ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
static void applyToAm(AmRegistrationData data, RepriseDossier dossier) {
|
||||
final photo = _photoUrl;
|
||||
data.resetForReprise(
|
||||
firstName: dossier.prenom ?? '',
|
||||
lastName: dossier.nom ?? '',
|
||||
phone: dossier.telephone ?? '',
|
||||
email: dossier.email,
|
||||
streetAddress: dossier.adresse ?? '',
|
||||
postalCode: dossier.codePostal ?? '',
|
||||
city: dossier.ville ?? '',
|
||||
existingPhotoUrl: photo,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user