From e08e1147eff62ca0c237448c59491728c2aa88ca Mon Sep 17 00:00:00 2001
From: Etienne Loupias <eloupias@grandlyon.com>
Date: Wed, 12 Mar 2025 17:17:45 +0100
Subject: [PATCH] add FindOrientationDto

---
 src/orientation/dto/findOrientation.dto.ts | 6 ++++++
 src/orientation/dto/orientation.dto.ts     | 8 ++++----
 src/orientation/orientation.service.ts     | 7 ++++---
 3 files changed, 14 insertions(+), 7 deletions(-)
 create mode 100644 src/orientation/dto/findOrientation.dto.ts

diff --git a/src/orientation/dto/findOrientation.dto.ts b/src/orientation/dto/findOrientation.dto.ts
new file mode 100644
index 000000000..476ef01c6
--- /dev/null
+++ b/src/orientation/dto/findOrientation.dto.ts
@@ -0,0 +1,6 @@
+import { IOrientation } from '../interfaces/orientation.interface';
+
+export class FindOrientationDto {
+  myOrientations: { inProgress: IOrientation[]; history: IOrientation[] };
+  todoOrientations: { inProgress: IOrientation[]; history: IOrientation[] };
+}
diff --git a/src/orientation/dto/orientation.dto.ts b/src/orientation/dto/orientation.dto.ts
index 9b4a2446e..4d2bbd27a 100644
--- a/src/orientation/dto/orientation.dto.ts
+++ b/src/orientation/dto/orientation.dto.ts
@@ -56,7 +56,7 @@ class DateSlotDto {
   hours: string;
 }
 
-export class customStructureDto {
+export class CustomStructureDto {
   @ApiProperty()
   @IsString()
   @IsNotEmpty()
@@ -132,9 +132,9 @@ export class OrientationDto {
   @IsString()
   orientator?: string;
 
-  @ApiPropertyOptional({ type: () => customStructureDto })
-  @Type(() => customStructureDto)
-  structureOrientator: string | customStructureDto;
+  @ApiPropertyOptional({ type: () => CustomStructureDto })
+  @Type(() => CustomStructureDto)
+  structureOrientator: string | CustomStructureDto;
 
   @ApiProperty({ enum: ['pending', 'acknowledged', 'completed', 'uncompleted', 'expired'] })
   @IsNotEmpty()
diff --git a/src/orientation/orientation.service.ts b/src/orientation/orientation.service.ts
index e44b74514..2d4ca714d 100644
--- a/src/orientation/orientation.service.ts
+++ b/src/orientation/orientation.service.ts
@@ -1,11 +1,12 @@
 import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
 import { InjectModel } from '@nestjs/mongoose';
 import mongoose, { Model } from 'mongoose';
-import { customStructureDto, OrientationDto } from './dto/orientation.dto';
+import { CustomStructureDto, OrientationDto } from './dto/orientation.dto';
 import { IOrientation } from './interfaces/orientation.interface';
 import { Orientation, OrientationDocument } from './orientation.schema';
 import { CategoriesService } from '../categories/services/categories.service';
 import { UsersService } from '../users/services/users.service';
+import { FindOrientationDto } from './dto/findOrientation.dto';
 
 @Injectable()
 export class OrientationService {
@@ -37,7 +38,7 @@ export class OrientationService {
     }
   }
 
-  public async find(userId: string, structureId: string = null): Promise<any> {
+  public async find(userId: string, structureId: string = null): Promise<FindOrientationDto> {
     try {
       const historyStatus = ['completed', 'uncompleted', 'expired'];
       let myOrientationsFilters;
@@ -110,7 +111,7 @@ export class OrientationService {
   /**
    * Helper method to populate structure by ID
    */
-  private async populateStructureById(structureId: string): Promise<string | customStructureDto | null> {
+  private async populateStructureById(structureId: string): Promise<string | CustomStructureDto | null> {
     try {
       const structure = await this.OrientationModel.db
         .collection('structures')
-- 
GitLab