Compare commits

..
5 Commits
Author SHA1 Message Date
jmartinandCursor e6be1dffc4 feat(#207): polish affichage bulles soin + icônes sous-types
Layout type congés (date/heure puis détail italique), assets flacon/pansement/thermo_verre.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 16:46:29 +02:00
jmartinandCursor cec1fc2ba7 feat(front): alignement avec la spec backend soins enfant
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 16:46:29 +02:00
jmartinandCursor 1c0ff71f26 feat(front): implémentation UI soins enfant (#207)
- Ajout des formulaires spécifiques (fièvre, bobo, médicament) dans la modale d'ajout
- Formatage personnalisé du résumé des soins dans le feed
- Boutons supprimer / corriger (24h) pour l'AM
- Icônes contextuelles selon le sous-type de soin

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 16:46:29 +02:00
jmartinandCursor a5d1616a17 fix(cards): resolve typescript errors with payload typing
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-08 18:09:15 +02:00
jmartinandCursor 1e4e2d5198 fix(cards): allow payload object in DTOs
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-08 18:03:24 +02:00
7 changed files with 118 additions and 56 deletions
+40 -40
View File
@@ -137,7 +137,7 @@ export class CardsService {
const absenceType = this.mapAbsenceType(dto.type_code);
let motif = dto.motif ?? null;
let finalPayload = {
let finalPayload: Record<string, any> = {
date_debut: dto.date_debut,
date_fin: dto.date_fin,
motif,
@@ -145,40 +145,40 @@ export class CardsService {
};
if (dto.type_code === 'soin_enfant') {
const p = dto.payload;
if (!p || !p.sous_type || !p.heure_releve) {
const p = dto.payload as Record<string, any>;
if (!p || !p?.sous_type || !p?.heure_releve) {
throw new BadRequestException('sous_type et heure_releve requis pour soin_enfant');
}
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p.heure_releve)) {
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p?.heure_releve)) {
throw new BadRequestException('Format heure_releve invalide (HH:mm)');
}
if (p.sous_type === 'fievre') {
if (typeof p.temperature_c !== 'number' || p.temperature_c < 34.0 || p.temperature_c > 43.0) {
if (p?.sous_type === 'fievre') {
if (typeof p?.temperature_c !== 'number' || p?.temperature_c < 34.0 || p?.temperature_c > 43.0) {
throw new BadRequestException('temperature_c invalide (34.0 - 43.0)');
}
motif = `${p.temperature_c.toFixed(1).replace('.', ',')} °C à ${p.heure_releve}`;
if (p.medicament_donne && typeof p.medicament_donne === 'string' && p.medicament_donne.trim()) {
motif += ` (Médicament : ${p.medicament_donne.trim()})`;
motif = `${p?.temperature_c.toFixed(1).replace('.', ',')} °C à ${p?.heure_releve}`;
if (p?.medicament_donne && typeof p?.medicament_donne === 'string' && p?.medicament_donne.trim()) {
motif += ` (Médicament : ${p?.medicament_donne.trim()})`;
}
} else if (p.sous_type === 'bobo') {
} else if (p?.sous_type === 'bobo') {
const natures = ['chute', 'coup', 'egratignure', 'piqure', 'brulure', 'autre'];
if (!natures.includes(p.bobo_nature)) {
if (!natures.includes(p?.bobo_nature)) {
throw new BadRequestException('bobo_nature invalide');
}
motif = `Bobo (${p.bobo_nature}) à ${p.heure_releve}`;
if (p.description && typeof p.description === 'string' && p.description.trim()) {
const desc = p.description.trim();
motif = `Bobo (${p?.bobo_nature}) à ${p?.heure_releve}`;
if (p?.description && typeof p?.description === 'string' && p?.description.trim()) {
const desc = p?.description.trim();
if (desc.length > 120) throw new BadRequestException('description trop longue (max 120)');
motif += ` : ${desc.length > 30 ? desc.substring(0, 30) + '...' : desc}`;
}
} else if (p.sous_type === 'medicament') {
if (!p.medicament_nom || typeof p.medicament_nom !== 'string' || !p.medicament_nom.trim()) {
} else if (p?.sous_type === 'medicament') {
if (!p?.medicament_nom || typeof p?.medicament_nom !== 'string' || !p?.medicament_nom.trim()) {
throw new BadRequestException('medicament_nom requis');
}
motif = `Médicament (${p.medicament_nom.trim()}) à ${p.heure_releve}`;
if (p.contexte && typeof p.contexte === 'string' && p.contexte.trim()) {
if (p.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
motif = `Médicament (${p?.medicament_nom.trim()}) à ${p?.heure_releve}`;
if (p?.contexte && typeof p?.contexte === 'string' && p?.contexte.trim()) {
if (p?.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
}
} else {
throw new BadRequestException('sous_type invalide pour soin_enfant');
@@ -192,7 +192,7 @@ export class CardsService {
type: absenceType,
date_debut: dto.date_debut,
date_fin: dto.date_fin,
motif: motif ?? undefined,
motif: motif ? String(motif) : undefined,
});
absenceId = absence.id;
} else {
@@ -205,7 +205,7 @@ export class CardsService {
await this.evenementsService.maj(userId, role, absenceId, {
date_debut: dto.date_debut,
date_fin: dto.date_fin,
motif: motif ?? undefined,
motif: motif ? String(motif) : undefined,
// Congé accepté modifié → repasse en attente via cartes respond flow;
// pour absence enfant update immédiat déjà fait.
...(dto.type_code === 'conge_am'
@@ -352,7 +352,7 @@ export class CardsService {
}
let motif = dto.motif ?? card.payload?.['motif'] ?? null;
let finalPayload = {
let finalPayload: Record<string, any> = {
...card.payload,
date_debut: debut,
date_fin: fin,
@@ -361,39 +361,39 @@ export class CardsService {
if (card.type_code === 'soin_enfant') {
const p = finalPayload;
if (!p || !p.sous_type || !p.heure_releve) {
if (!p || !p?.sous_type || !p?.heure_releve) {
throw new BadRequestException('sous_type et heure_releve requis pour soin_enfant');
}
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p.heure_releve)) {
if (!/^([01]\d|2[0-3]):([0-5]\d)$/.test(p?.heure_releve)) {
throw new BadRequestException('Format heure_releve invalide (HH:mm)');
}
if (p.sous_type === 'fievre') {
if (typeof p.temperature_c !== 'number' || p.temperature_c < 34.0 || p.temperature_c > 43.0) {
if (p?.sous_type === 'fievre') {
if (typeof p?.temperature_c !== 'number' || p?.temperature_c < 34.0 || p?.temperature_c > 43.0) {
throw new BadRequestException('temperature_c invalide (34.0 - 43.0)');
}
motif = `${p.temperature_c.toFixed(1).replace('.', ',')} °C à ${p.heure_releve}`;
if (p.medicament_donne && typeof p.medicament_donne === 'string' && p.medicament_donne.trim()) {
motif += ` (Médicament : ${p.medicament_donne.trim()})`;
motif = `${p?.temperature_c.toFixed(1).replace('.', ',')} °C à ${p?.heure_releve}`;
if (p?.medicament_donne && typeof p?.medicament_donne === 'string' && p?.medicament_donne.trim()) {
motif += ` (Médicament : ${p?.medicament_donne.trim()})`;
}
} else if (p.sous_type === 'bobo') {
} else if (p?.sous_type === 'bobo') {
const natures = ['chute', 'coup', 'egratignure', 'piqure', 'brulure', 'autre'];
if (!natures.includes(p.bobo_nature)) {
if (!natures.includes(p?.bobo_nature)) {
throw new BadRequestException('bobo_nature invalide');
}
motif = `Bobo (${p.bobo_nature}) à ${p.heure_releve}`;
if (p.description && typeof p.description === 'string' && p.description.trim()) {
const desc = p.description.trim();
motif = `Bobo (${p?.bobo_nature}) à ${p?.heure_releve}`;
if (p?.description && typeof p?.description === 'string' && p?.description.trim()) {
const desc = p?.description.trim();
if (desc.length > 120) throw new BadRequestException('description trop longue (max 120)');
motif += ` : ${desc.length > 30 ? desc.substring(0, 30) + '...' : desc}`;
}
} else if (p.sous_type === 'medicament') {
if (!p.medicament_nom || typeof p.medicament_nom !== 'string' || !p.medicament_nom.trim()) {
} else if (p?.sous_type === 'medicament') {
if (!p?.medicament_nom || typeof p?.medicament_nom !== 'string' || !p?.medicament_nom.trim()) {
throw new BadRequestException('medicament_nom requis');
}
motif = `Médicament (${p.medicament_nom.trim()}) à ${p.heure_releve}`;
if (p.contexte && typeof p.contexte === 'string' && p.contexte.trim()) {
if (p.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
motif = `Médicament (${p?.medicament_nom.trim()}) à ${p?.heure_releve}`;
if (p?.contexte && typeof p?.contexte === 'string' && p?.contexte.trim()) {
if (p?.contexte.trim().length > 120) throw new BadRequestException('contexte trop long (max 120)');
}
} else {
throw new BadRequestException('sous_type invalide pour soin_enfant');
@@ -418,7 +418,7 @@ export class CardsService {
await this.evenementsService.maj(userId, role, card.id_evenement, {
date_debut: debut,
date_fin: fin,
motif: motif ?? undefined,
motif: motif ? String(motif) : undefined,
...(card.type_code !== 'soin_enfant' ? { statut: StatutEvenementAgendaType.EN_ATTENTE } : {}),
});
}
@@ -3,6 +3,7 @@ import {
IsDateString,
IsEnum,
IsOptional,
IsObject,
IsString,
IsUUID,
MaxLength,
@@ -51,6 +52,7 @@ export class CreerCarteDto {
@ApiPropertyOptional()
@IsOptional()
@IsObject()
payload?: Record<string, any>;
}
@@ -86,6 +88,7 @@ export class MajCarteDto {
@ApiPropertyOptional()
@IsOptional()
@IsObject()
payload?: Record<string, any>;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

+52 -7
View File
@@ -110,11 +110,56 @@ class CarteBulle {
String? get dateDebut => payload['date_debut']?.toString();
String? get dateFin => payload['date_fin']?.toString();
String? get motif => payload['motif']?.toString();
/// Helper pour extraire les informations de soin
String? get resumerSoin {
/// Heure de relevé (payload soins), format API `HH:mm`.
String? get heureReleve => payload['heure_releve']?.toString();
/// Heure affichable `18h19` (depuis `heure_releve`).
String? get heureReleveAffichee {
final h = heureReleve?.trim();
if (h == null || h.isEmpty) return null;
final parts = h.split(':');
if (parts.length < 2) return h;
return '${parts[0]}h${parts[1]}';
}
/// Ligne détail soin (sans date/heure) — sous la ligne agenda.
String? get detailSoin {
if (!isSoinEnfant) return null;
return payload['motif']?.toString();
final st = payload['sous_type']?.toString();
if (st == 'fievre') {
final t = payload['temperature_c'];
final med = payload['medicament_donne']?.toString().trim();
String? temp;
if (t is num) {
temp = t.toStringAsFixed(1).replaceAll('.', ',');
} else if (t != null) {
temp = t.toString().replaceAll('.', ',');
}
if (temp == null || temp.isEmpty) return motif;
var s = '$temp °C';
if (med != null && med.isNotEmpty) {
s += ' (Médicament : $med)';
}
return s;
}
if (st == 'bobo') {
final nature = payload['bobo_nature']?.toString() ?? 'bobo';
final desc = payload['description']?.toString().trim();
if (desc != null && desc.isNotEmpty) {
return 'Bobo ($nature) : $desc';
}
return 'Bobo ($nature)';
}
if (st == 'medicament') {
final nom = payload['medicament_nom']?.toString().trim();
final ctx = payload['contexte']?.toString().trim();
final label =
(nom != null && nom.isNotEmpty) ? 'Médicament ($nom)' : 'Médicament';
if (ctx != null && ctx.isNotEmpty) return '$label : $ctx';
return label;
}
return motif;
}
/// Motif de refus : réponse API, sinon motif payload (co-parent / reload).
@@ -174,9 +219,9 @@ class CarteBulle {
return 'assets/images/sac_lapin.png';
case 'soin_enfant':
final st = payload['sous_type']?.toString();
if (st == 'fievre') return 'assets/images/thermo_croix.png';
if (st == 'medicament') return 'assets/images/cuillere.png'; // Using generic fallback or specific if added later. Assuming thermo_croix or similar could work.
if (st == 'bobo') return 'assets/images/sac_lapin.png'; // Will adjust these later if better assets exist. Let's use generic ones for now, or null if no appropriate assets.
if (st == 'fievre') return 'assets/images/thermo_verre.png';
if (st == 'bobo') return 'assets/images/pansement.png';
if (st == 'medicament') return 'assets/images/flacon.png';
return null;
default:
return null;
@@ -612,12 +612,15 @@ class _BulleTile extends StatelessWidget {
}
String _fmtPeriodeUneLigne() {
// Si c'est un soin_enfant en singleDay, on affiche juste "Le ..." ou un résumé si pertinent
// Soin : « Le 08 octobre 2026 à 18h19 » (détail en italique sous la ligne).
if (card.isSoinEnfant) {
final resume = card.resumerSoin;
final jour = card.dateDebut != null ? 'Le ${_fmtLong(card.dateDebut)}' : '';
if (resume != null) return '$jour\n$resume';
return jour;
final jour = card.dateDebut != null
? 'Le ${_fmtLong(card.dateDebut)}'
: '';
final h = card.heureReleveAffichee;
if (jour.isEmpty) return h != null ? 'À $h' : '';
if (h == null || h.isEmpty) return jour;
return '$jour à $h';
}
final d1 = DateTime.tryParse(card.dateDebut ?? '');
@@ -723,8 +726,6 @@ class _BulleTile extends StatelessWidget {
Expanded(
child: Text(
periode,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.merienda(
fontSize: 15,
fontWeight: FontWeight.w600,
@@ -736,14 +737,27 @@ class _BulleTile extends StatelessWidget {
],
),
],
if (card.isSoinEnfant &&
(card.detailSoin?.trim().isNotEmpty ?? false)) ...[
const SizedBox(height: 8),
Text(
card.detailSoin!,
softWrap: true,
style: GoogleFonts.merriweather(
fontSize: 13,
fontStyle: FontStyle.italic,
height: 1.35,
color: encre.ink,
),
),
],
if (card.isCongeAm &&
card.statut == CarteStatut.refusee &&
card.motifRefus != null) ...[
const SizedBox(height: 8),
Text(
'Motif : ${card.motifRefus}',
maxLines: 4,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: GoogleFonts.merriweather(
fontSize: 13,
fontStyle: FontStyle.italic,