mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 05:42:27 +00:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { DocumentMetaResponseDto } from '~/document/dtos/response';
|
|
import { SavingGoal } from '~/saving-goals/entities';
|
|
import { CategoryResponseDto } from './category-response.dto';
|
|
|
|
export class SavingGoalDetailsResponseDto {
|
|
@ApiProperty()
|
|
id!: string;
|
|
|
|
@ApiProperty()
|
|
name!: string;
|
|
|
|
@ApiPropertyOptional()
|
|
description?: string;
|
|
|
|
@ApiProperty()
|
|
dueDate!: Date;
|
|
|
|
@ApiProperty()
|
|
targetAmount!: number;
|
|
|
|
@ApiProperty()
|
|
currentAmount!: number;
|
|
|
|
@ApiPropertyOptional({ type: CategoryResponseDto, isArray: true })
|
|
categories?: CategoryResponseDto[];
|
|
|
|
@ApiPropertyOptional({ type: DocumentMetaResponseDto, isArray: true })
|
|
image: DocumentMetaResponseDto | null;
|
|
|
|
@ApiProperty()
|
|
createdAt!: Date;
|
|
|
|
@ApiProperty()
|
|
updatedAt!: Date;
|
|
|
|
constructor(data: SavingGoal) {
|
|
this.id = data.id;
|
|
this.name = data.name;
|
|
this.description = data.description;
|
|
this.dueDate = data.dueDate;
|
|
this.targetAmount = data.targetAmount;
|
|
this.currentAmount = data.currentAmount;
|
|
this.categories = data.categories ? data.categories.map((category) => new CategoryResponseDto(category)) : [];
|
|
this.image = data.image ? new DocumentMetaResponseDto(data.image) : null;
|
|
this.createdAt = data.createdAt;
|
|
this.updatedAt = data.updatedAt;
|
|
}
|
|
}
|