Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5d1616a17 | ||
|
|
1e4e2d5198 |
@@ -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>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user