From 68476091bbd97b713741ad55c01d5ac7bd34eef6 Mon Sep 17 00:00:00 2001
From: Etienne Loupias <eloupias@grandlyon.com>
Date: Thu, 13 Mar 2025 11:10:10 +0100
Subject: [PATCH] rename endpoint dashboard

---
 src/orientation/dto/findOrientation.dto.ts |  4 ++++
 src/orientation/orientation.controller.ts  | 21 +++++++++++----------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/orientation/dto/findOrientation.dto.ts b/src/orientation/dto/findOrientation.dto.ts
index 476ef01c6..aca199194 100644
--- a/src/orientation/dto/findOrientation.dto.ts
+++ b/src/orientation/dto/findOrientation.dto.ts
@@ -1,6 +1,10 @@
+import { ApiProperty } from '@nestjs/swagger';
 import { IOrientation } from '../interfaces/orientation.interface';
 
 export class FindOrientationDto {
+  @ApiProperty()
   myOrientations: { inProgress: IOrientation[]; history: IOrientation[] };
+
+  @ApiProperty()
   todoOrientations: { inProgress: IOrientation[]; history: IOrientation[] };
 }
diff --git a/src/orientation/orientation.controller.ts b/src/orientation/orientation.controller.ts
index 19113b589..997488c34 100644
--- a/src/orientation/orientation.controller.ts
+++ b/src/orientation/orientation.controller.ts
@@ -6,6 +6,7 @@ import { OrientationService } from './orientation.service';
 import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
 import { RolesGuard } from '../users/guards/roles.guard';
 import { Roles } from '../users/decorators/roles.decorator';
+import { FindOrientationDto } from './dto/findOrientation.dto';
 
 @ApiTags('orientation')
 @Controller('orientation')
@@ -15,16 +16,6 @@ export class OrientationController {
   constructor(private orientationService: OrientationService) {}
 
   @Get()
-  @UseGuards(JwtAuthGuard)
-  @ApiOperation({ summary: 'Get user orientations' })
-  @ApiResponse({ status: 200, description: 'Return user orientations with populated details.' })
-  @ApiResponse({ status: 500, description: 'Internal server error.' })
-  public async find(@Request() req, @Query('structureId') structureId?: string): Promise<any> {
-    this.logger.debug(`find for user=${req.user._id}, structureId=${structureId}`);
-    return this.orientationService.find(req.user._id, structureId);
-  }
-
-  @Get('admin')
   @UseGuards(JwtAuthGuard, RolesGuard)
   @Roles('admin')
   @ApiOperation({ summary: 'Get all orientations with full details' })
@@ -35,6 +26,16 @@ export class OrientationController {
     return this.orientationService.findAll();
   }
 
+  @Get('dashboard')
+  @UseGuards(JwtAuthGuard)
+  @ApiOperation({ summary: 'Get user orientations' })
+  @ApiResponse({ status: 200, description: 'Return user orientations with populated details.' })
+  @ApiResponse({ status: 500, description: 'Internal server error.' })
+  public async getDashboard(@Request() req, @Query('structureId') structureId?: string): Promise<FindOrientationDto> {
+    this.logger.debug(`find for user=${req.user._id}, structureId=${structureId}`);
+    return this.orientationService.find(req.user._id, structureId);
+  }
+
   @Post()
   @UseGuards(JwtAuthGuard)
   @ApiOperation({ summary: 'Save a new orientation' })
-- 
GitLab