73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
class Child {
|
|
final String id;
|
|
final String firstName;
|
|
final String lastName;
|
|
final DateTime? birthDate;
|
|
final DateTime? expectedBirthDate;
|
|
final String? photoUrl;
|
|
final bool hasPhotoConsent;
|
|
final DateTime? photoConsentDate;
|
|
final String status; // 'unborn', 'active', 'schooled'
|
|
final List<String> parentIds;
|
|
final bool isMultipleBirth; // true pour jumeaux, triplés, etc.
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
|
|
Child({
|
|
required this.id,
|
|
required this.firstName,
|
|
required this.lastName,
|
|
this.birthDate,
|
|
this.expectedBirthDate,
|
|
this.photoUrl,
|
|
required this.hasPhotoConsent,
|
|
this.photoConsentDate,
|
|
required this.status,
|
|
required this.parentIds,
|
|
required this.isMultipleBirth,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
factory Child.fromJson(Map<String, dynamic> json) {
|
|
return Child(
|
|
id: json['id'],
|
|
firstName: json['firstName'],
|
|
lastName: json['lastName'],
|
|
birthDate: json['birthDate'] != null
|
|
? DateTime.parse(json['birthDate'])
|
|
: null,
|
|
expectedBirthDate: json['expectedBirthDate'] != null
|
|
? DateTime.parse(json['expectedBirthDate'])
|
|
: null,
|
|
photoUrl: json['photoUrl'],
|
|
hasPhotoConsent: json['hasPhotoConsent'] ?? false,
|
|
photoConsentDate: json['photoConsentDate'] != null
|
|
? DateTime.parse(json['photoConsentDate'])
|
|
: null,
|
|
status: json['status'] ?? 'unborn',
|
|
parentIds: List<String>.from(json['parentIds'] ?? []),
|
|
isMultipleBirth: json['isMultipleBirth'] ?? false,
|
|
createdAt: DateTime.parse(json['createdAt']),
|
|
updatedAt: DateTime.parse(json['updatedAt']),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'firstName': firstName,
|
|
'lastName': lastName,
|
|
'birthDate': birthDate?.toIso8601String(),
|
|
'expectedBirthDate': expectedBirthDate?.toIso8601String(),
|
|
'photoUrl': photoUrl,
|
|
'hasPhotoConsent': hasPhotoConsent,
|
|
'photoConsentDate': photoConsentDate?.toIso8601String(),
|
|
'status': status,
|
|
'parentIds': parentIds,
|
|
'isMultipleBirth': isMultipleBirth,
|
|
'createdAt': createdAt.toIso8601String(),
|
|
'updatedAt': updatedAt.toIso8601String(),
|
|
};
|
|
}
|
|
} |