- Frontend:
- Create UserService to handle user-related API calls (gestionnaires, parents, AMs, admins)
- Update AdminDashboardScreen to use dynamic widgets
- Implement dynamic management widgets:
- GestionnaireManagementWidget
- ParentManagementWidget
- AssistanteMaternelleManagementWidget
- AdminManagementWidget
- Add data models: ParentModel, AssistanteMaternelleModel
- Update AppUser model
- Update ApiConfig
- Backend:
- Update controllers (Parents, AMs, Gestionnaires, Users) to allow ADMINISTRATEUR role to list users
- Note: Gestionnaires endpoint is currently bypassed in frontend (using /users filter) due to module import issue (documented in docs/92_NOTE-BACKEND-GESTIONNAIRES.md)
- Docs:
- Add note about backend fix for Gestionnaires module
- Update .cursorrules to forbid worktrees
Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
} from '@nestjs/common';
|
|
import { ParentsService } from './parents.service';
|
|
import { Parents } from 'src/entities/parents.entity';
|
|
import { Roles } from 'src/common/decorators/roles.decorator';
|
|
import { RoleType } from 'src/entities/users.entity';
|
|
import { ApiBody, ApiResponse, ApiTags } from '@nestjs/swagger';
|
|
import { CreateParentDto } from '../user/dto/create_parent.dto';
|
|
import { UpdateParentsDto } from '../user/dto/update_parent.dto';
|
|
|
|
@ApiTags('Parents')
|
|
@Controller('parents')
|
|
export class ParentsController {
|
|
constructor(private readonly parentsService: ParentsService) {}
|
|
|
|
@Roles(RoleType.SUPER_ADMIN, RoleType.GESTIONNAIRE, RoleType.ADMINISTRATEUR)
|
|
@Get()
|
|
@ApiResponse({ status: 200, type: [Parents], description: 'Liste des parents' })
|
|
@ApiResponse({ status: 403, description: 'Accès refusé !' })
|
|
getAll(): Promise<Parents[]> {
|
|
return this.parentsService.findAll();
|
|
}
|
|
|
|
@Roles(RoleType.SUPER_ADMIN, RoleType.GESTIONNAIRE)
|
|
@Get(':id')
|
|
@ApiResponse({ status: 200, type: Parents, description: 'Détails du parent par ID utilisateur' })
|
|
@ApiResponse({ status: 404, description: 'Parent non trouvé' })
|
|
@ApiResponse({ status: 403, description: 'Accès refusé !' })
|
|
getOne(@Param('id') user_id: string): Promise<Parents> {
|
|
return this.parentsService.findOne(user_id);
|
|
}
|
|
|
|
@Roles(RoleType.SUPER_ADMIN, RoleType.GESTIONNAIRE)
|
|
@Post()
|
|
@ApiBody({ type: CreateParentDto })
|
|
@ApiResponse({ status: 201, type: Parents, description: 'Parent créé avec succès' })
|
|
@ApiResponse({ status: 403, description: 'Accès refusé !' })
|
|
create(@Body() dto: CreateParentDto): Promise<Parents> {
|
|
return this.parentsService.create(dto);
|
|
}
|
|
|
|
@Roles(RoleType.SUPER_ADMIN, RoleType.GESTIONNAIRE)
|
|
@Patch(':id')
|
|
@ApiBody({ type: UpdateParentsDto })
|
|
@ApiResponse({ status: 200, type: Parents, description: 'Parent mis à jour avec succès' })
|
|
@ApiResponse({ status: 404, description: 'Parent introuvable' })
|
|
@ApiResponse({ status: 403, description: 'Accès refusé !' })
|
|
update(@Param('id') id: string, @Body() dto: UpdateParentsDto): Promise<Parents> {
|
|
return this.parentsService.update(id, dto);
|
|
}
|
|
}
|