36 lines
961 B
Dart
36 lines
961 B
Dart
/// Le compte fidélité du client connecté. Le [code] est encodé dans son QR.
|
|
class Client {
|
|
final String id; // id PocketBase
|
|
final String code; // ex : « FID-3F9K2A »
|
|
final String nom;
|
|
final String? prenom;
|
|
final String? telephone;
|
|
final double points;
|
|
|
|
const Client({
|
|
required this.id,
|
|
required this.code,
|
|
required this.nom,
|
|
this.prenom,
|
|
this.telephone,
|
|
this.points = 0,
|
|
});
|
|
|
|
/// Nom complet affiché : « Prénom Nom » (ou juste le nom si pas de prénom).
|
|
String get nomComplet {
|
|
final p = (prenom ?? '').trim();
|
|
return p.isEmpty ? nom : '$p $nom';
|
|
}
|
|
|
|
factory Client.fromMap(Map<String, dynamic> map) {
|
|
return Client(
|
|
id: map['id'].toString(),
|
|
code: (map['code'] as String?) ?? '',
|
|
nom: (map['nom'] as String?) ?? '',
|
|
prenom: map['prenom'] as String?,
|
|
telephone: map['telephone'] as String?,
|
|
points: (map['points'] as num?)?.toDouble() ?? 0,
|
|
);
|
|
}
|
|
}
|