import { ApiProperty } from '@nestjs/swagger'; import { Gender } from '~/customer/enums'; import { Guardian } from '~/guardian/entities/guradian.entity'; import { Junior } from '~/junior/entities'; import { ChildRelationshipLabel, GuardianRelationship, Relationship } from '~/junior/enums'; export class QrCodeValidationDetailsResponse { @ApiProperty() fullname!: string; @ApiProperty() phoneNumber!: string; @ApiProperty() email!: string; @ApiProperty() relationship?: string; @ApiProperty() dateOfBirth!: Date; constructor(junior: Junior, guardian?: Guardian) { const person = guardian ? guardian : junior; this.fullname = `${person.customer.firstName} ${person.customer.lastName}`; this.phoneNumber = person.customer.user.phoneNumber; this.email = person.customer.user.email; this.dateOfBirth = person.customer.dateOfBirth; if (guardian) { this.relationship = junior.relationship; } else { if (junior.relationship === Relationship.PARENT) { this.relationship = junior.customer.gender === Gender.MALE ? ChildRelationshipLabel.SON : ChildRelationshipLabel.DAUGHTER; } else { this.relationship = GuardianRelationship[junior.relationship]; } } } }