Files
petitspas/backend/src/modules/evenements-agenda/dto/evenements-agenda.dto.ts
T
jmartinandCursor 63094fe49d feat(#215): GET événement agenda + DTO enrichi
Ajoute GET /evenements-agenda/:id, enrichit le DTO (id_lot, heure,
statut_lot, statut_effectif, actions, libelle_refus anonymisé) et
autorise la lecture sur placement terminé.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-16 16:44:51 +02:00

198 lines
4.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
IsDateString,
IsEnum,
IsOptional,
IsString,
IsUUID,
MaxLength,
MinLength,
} from 'class-validator';
import {
StatutEvenementAgendaType,
TypeEvenementAgendaType,
} from 'src/entities/evenements_agenda.entity';
import { AgendaLotStatutType } from 'src/entities/agenda_lots.entity';
export class CreerEvenementAgendaDto {
@ApiProperty({ description: 'Placement AM↔enfant (couple)' })
@IsUUID()
id_placement: string;
@ApiProperty({ enum: TypeEvenementAgendaType })
@IsEnum(TypeEvenementAgendaType)
type: TypeEvenementAgendaType;
@ApiProperty({ example: '2026-10-01' })
@IsDateString()
date_debut: string;
@ApiProperty({ example: '2026-10-05' })
@IsDateString()
date_fin: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(2000)
motif?: string;
}
export class MajEvenementAgendaDto {
@ApiPropertyOptional({ example: '2026-10-02' })
@IsOptional()
@IsDateString()
date_debut?: string;
@ApiPropertyOptional({ example: '2026-10-06' })
@IsOptional()
@IsDateString()
date_fin?: string;
@ApiPropertyOptional({ enum: StatutEvenementAgendaType })
@IsOptional()
@IsEnum(StatutEvenementAgendaType)
statut?: StatutEvenementAgendaType;
@ApiPropertyOptional({
description: 'Motivation de refus (parent) ou motif créateur',
})
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(2000)
motif?: string;
}
/** Droits calculés pour l’utilisateur courant — #215 */
export class EvenementAgendaActionsDto {
@ApiProperty({ description: 'Peut modifier dates / resoumettre (créateur)' })
peut_modifier: boolean;
@ApiProperty({ description: 'Peut annuler / soft-cancel (créateur)' })
peut_supprimer: boolean;
@ApiProperty({
description: 'Peut accept/refuse (parent habilité, congé en attente)',
})
peut_accepter_refuser: boolean;
@ApiProperty({
description: 'Peut ack informatif (ex. arrêt maladie)',
})
peut_ack: boolean;
}
export class EvenementAgendaDto {
@ApiProperty()
id: string;
@ApiProperty()
id_placement: string;
@ApiPropertyOptional({
description: 'Lot collectif (congé/arrêt/absence groupés)',
nullable: true,
})
id_lot?: string | null;
@ApiPropertyOptional({
description: 'Carte de collecte liée',
nullable: true,
})
id_card_instance?: string | null;
@ApiProperty({ enum: TypeEvenementAgendaType })
type: TypeEvenementAgendaType;
@ApiProperty({ example: '2026-10-01' })
date_debut: string;
@ApiProperty({ example: '2026-10-05' })
date_fin: string;
@ApiPropertyOptional({
example: '18:19',
description: 'Heure métier (soin), HH:mm',
nullable: true,
})
heure?: string | null;
@ApiProperty({
enum: StatutEvenementAgendaType,
description: 'Statut de cet événement (membre du lot si lot)',
})
statut: StatutEvenementAgendaType;
@ApiPropertyOptional({
enum: AgendaLotStatutType,
description: 'Statut global du lot ; null si hors lot',
nullable: true,
})
statut_lot?: AgendaLotStatutType | null;
@ApiProperty({
enum: StatutEvenementAgendaType,
description:
'Statut à afficher pour l’utilisateur courant (peut différer du membre si lot refusé / nouvel accueil)',
})
statut_effectif: StatutEvenementAgendaType;
@ApiProperty()
expire_at: string;
@ApiPropertyOptional({ nullable: true })
verrouille_le?: string | null;
@ApiPropertyOptional({ nullable: true })
refuse_le?: string | null;
@ApiPropertyOptional({ nullable: true })
annule_le?: string | null;
@ApiPropertyOptional()
cree_par?: string | null;
@ApiPropertyOptional({
description: 'Motif créateur ou texte de refus (sans nommer la famille)',
nullable: true,
})
motif?: string | null;
@ApiPropertyOptional({
description:
'Libellé de refus anonymisé : « Refusé par une autre famille » / « Refusé par l\'autre parent »',
nullable: true,
})
libelle_refus?: string | null;
@ApiPropertyOptional()
id_enfant?: string | null;
@ApiPropertyOptional()
prenom_enfant?: string | null;
@ApiPropertyOptional()
id_am?: string | null;
@ApiPropertyOptional()
prenom_am?: string | null;
@ApiPropertyOptional()
nom_am?: string | null;
@ApiProperty({ type: EvenementAgendaActionsDto })
actions: EvenementAgendaActionsDto;
@ApiProperty()
cree_le: string;
@ApiProperty()
modifie_le: string;
}
export class ListeEvenementsAgendaDto {
@ApiProperty({ type: [EvenementAgendaDto] })
items: EvenementAgendaDto[];
}