11import { ApiProperty , OmitType , PartialType } from "@nestjs/swagger" ;
22import { Type } from "class-transformer" ;
3- import { IsOptional , IsDate , Min , Max } from "class-validator" ;
4- import { QuestionnaireDto } from "../questionnaires/questionnaire.dto" ;
3+ import { IsOptional , Min , Max , IsMilitaryTime } from "class-validator" ;
54import { CarerDto } from "../../defaults/carers/carer.dto" ;
5+ import { EntryQuestionnaireDto , QuestionnaireDto } from "../questionnaires/questionnaire.dto" ;
6+ import { EntryLanguageCreationDto , EntryLanguageResponseDto } from "../entry-languages/entry-language.dto" ;
67
78export class EntryDto {
89 @ApiProperty ( { example : 1 , description : "The id of the entry" } )
910 id : number ;
1011
1112 @ApiProperty ( { example : "2024-11-01T07:00:00.000Z" , description : "The starting date of the entry" } )
12- @IsDate ( )
13+ @IsMilitaryTime ( )
1314 startedAt : string ;
1415
1516 @ApiProperty ( { example : "2024-11-01T08:00:00.00Z" , description : "The ending date of the entry" } )
16- @IsDate ( )
17+ @IsMilitaryTime ( )
1718 endedAt : string ;
1819
1920 @ApiProperty ( { example : 1 , description : "The weekday of the entry (Sunday is 0 like in JS)" } )
@@ -27,14 +28,21 @@ export class EntryDto {
2728 weeklyRecurring ?: number ;
2829
2930 @Type ( ( ) => QuestionnaireDto )
30- questionnaire : QuestionnaireDto ;
31+ questionnaire : EntryQuestionnaireDto ;
3132
3233 @Type ( ( ) => CarerDto )
3334 carer : CarerDto ;
3435
35- @Type ( ( ) => Array < number > )
36- entryLanguages : number [ ] ;
36+ @Type ( ( ) => Array < EntryLanguageResponseDto > )
37+ entryLanguages : Array < EntryLanguageResponseDto > ;
3738}
3839export class EntryResponseDto extends EntryDto { }
39- export class EntryCreationDto extends OmitType ( EntryDto , [ "id" ] ) { }
40+ export class QuestionnaireEntryDto extends OmitType ( EntryDto , [ "questionnaire" ] ) { }
41+ export class EntryCreationDto extends OmitType ( EntryDto , [ "id" , "carer" , "questionnaire" , "entryLanguages" ] ) {
42+ carer : number ;
43+ questionnaire : number ;
44+
45+ @Type ( ( ) => EntryLanguageCreationDto )
46+ entryLanguages : Array < EntryLanguageCreationDto > ;
47+ }
4048export class EntryMutationDto extends PartialType ( EntryCreationDto ) { }
0 commit comments