Skip to content

Commit 91bb7f7

Browse files
committed
fix(portails): utilisation clé fonction
1 parent 8a34104 commit 91bb7f7

File tree

16 files changed

+56
-72
lines changed

16 files changed

+56
-72
lines changed

.talismanrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
threshold: medium
2+
3+
file_ignore_config:
4+
- "**/*.test.ts"
5+
- "**/*.spec.ts"
6+
- "**/test/**"
7+
- "**/tests/**"
8+
19
fileignoreconfig:
210
- filename: _docs/dev/0.run-local-env.md
311
checksum: 855b6f29ace746c86597d36382dbe7e40f771137734e3bf5eb53c948d6592a74
@@ -27,5 +35,4 @@ fileignoreconfig:
2735
checksum: 0daf325477c634ee72587c4ab1210fdc5fd8dea1aa67a905f8842b7b6d13c6ca
2836
- filename: yarn.lock
2937
checksum: 08b8e5aa34abdbe885acc6d64dd693197644d94d976f0e1832760c3ed227c836
30-
threshold: medium
3138
version: "1.0"

packages/backend/src/_common/mocks/POST_USER_STRUCTURE_BODY.mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const POST_USER_STRUCTURE_BODY: Partial<UserStructure> = {
1212
nom: "TEST",
1313
prenom: "TEST",
1414
role: "admin" as UserStructureRole,
15-
fonction: "Président" as UserFonction,
15+
fonction: UserFonction.PRESIDENT,
1616
fonctionDetail: null,
1717
structure: {
1818
id: 100,

packages/backend/src/modules/portail-admin/dto/register-user-structure-admin.dto.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ import {
1111
} from "class-validator";
1212
import { Transform, TransformFnParams } from "class-transformer";
1313
import { LowerCaseTransform } from "../../../_common/decorators";
14-
import {
15-
UserStructureRole,
16-
USER_FONCTION_LABELS_LIST,
17-
UserFonction,
18-
USER_FONCTION_LABELS,
19-
} from "@domifa/common";
14+
import { UserStructureRole, UserFonction } from "@domifa/common";
2015

2116
export class RegisterUserStructureAdminDto {
2217
@ApiProperty({
@@ -52,7 +47,7 @@ export class RegisterUserStructureAdminDto {
5247
@MinLength(2)
5348
@MaxLength(100)
5449
@IsNotEmpty()
55-
@IsIn(USER_FONCTION_LABELS_LIST)
50+
@IsIn(Object.keys(UserFonction))
5651
public readonly fonction!: UserFonction;
5752

5853
@ApiProperty({
@@ -61,7 +56,7 @@ export class RegisterUserStructureAdminDto {
6156
@MinLength(2)
6257
@MaxLength(100)
6358
@IsString()
64-
@ValidateIf((u) => u.fonction === USER_FONCTION_LABELS.AUTRE)
59+
@ValidateIf((u) => u.fonction === UserFonction.AUTRE)
6560
@IsNotEmpty()
6661
@Transform(({ value }: TransformFnParams) => {
6762
if (value) {

packages/backend/src/modules/users/dto/user-edit.dto.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
USER_FONCTION_LABELS,
3-
USER_FONCTION_LABELS_LIST,
4-
UserFonction,
5-
} from "@domifa/common";
1+
import { UserFonction } from "@domifa/common";
62
import { ApiProperty } from "@nestjs/swagger";
73
import { Transform, TransformFnParams } from "class-transformer";
84
import {
@@ -48,7 +44,7 @@ export class UserEditDto {
4844
})
4945
@MinLength(2)
5046
@MaxLength(100)
51-
@IsIn(USER_FONCTION_LABELS_LIST)
47+
@IsIn(Object.keys(UserFonction))
5248
@IsString()
5349
public readonly fonction!: UserFonction;
5450

@@ -58,7 +54,7 @@ export class UserEditDto {
5854
@MinLength(2)
5955
@MaxLength(255)
6056
@IsString()
61-
@ValidateIf((u) => u.fonction === USER_FONCTION_LABELS.AUTRE)
57+
@ValidateIf((u) => u.fonction === UserFonction.AUTRE)
6258
@IsNotEmpty()
6359
@Transform(({ value }: TransformFnParams) => {
6460
if (value) {

packages/backend/src/modules/users/dto/user.dto.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ import {
1010
ValidateIf,
1111
} from "class-validator";
1212
import { IsValidPassword, Trim } from "../../../_common/decorators";
13-
import {
14-
StructureCommon,
15-
USER_FONCTION_LABELS,
16-
USER_FONCTION_LABELS_LIST,
17-
UserFonction,
18-
} from "@domifa/common";
13+
import { StructureCommon, UserFonction } from "@domifa/common";
1914

2015
export class UserDto {
2116
@MinLength(2)
@@ -36,14 +31,14 @@ export class UserDto {
3631

3732
@MinLength(2)
3833
@MaxLength(100)
39-
@IsIn(USER_FONCTION_LABELS_LIST)
34+
@IsIn(Object.keys(UserFonction))
4035
@IsString()
4136
public readonly fonction!: UserFonction;
4237

4338
@MinLength(2)
4439
@MaxLength(255)
4540
@IsString()
46-
@ValidateIf((u) => u.fonction === USER_FONCTION_LABELS.AUTRE)
41+
@ValidateIf((u) => u.fonction === UserFonction.AUTRE)
4742
@IsNotEmpty()
4843
public readonly fonctionDetail: string | null;
4944

packages/common/src/users/user-structure/constants/USER_FONCTION_LABELS.const.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,3 @@ export const USER_FONCTION_LABELS: {
2323
BENEVOLE: "Bénévole",
2424
AUTRE: "Autre",
2525
};
26-
27-
export const USER_FONCTION_LABELS_LIST = Object.values(USER_FONCTION_LABELS);

packages/frontend/src/app/modules/manage-users/components/edit-user/edit-user.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ <h2>Informations personnelles</h2>
9999
>
100100
<span class="question">Fonction</span>
101101
<span class="valeur">
102-
{{ me.fonction }}
102+
{{ USER_FONCTION_LABELS[me.fonction] }}
103103
</span>
104104
</p>
105105
<p *ngIf="me.fonctionDetail" class="col-md-6 reponses">

packages/frontend/src/app/modules/manage-users/components/edit-user/edit-user.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { map, takeUntil } from "rxjs/operators";
2020

2121
import { EmailValidator, NoWhiteSpaceValidator } from "../../../../shared";
2222
import { AuthService, CustomToastService } from "../../../shared/services";
23-
import { UserStructure } from "@domifa/common";
23+
import { USER_FONCTION_LABELS, UserStructure } from "@domifa/common";
2424
import { format } from "date-fns";
2525
import {
2626
UsagerLight,
@@ -59,7 +59,7 @@ export class EditUserComponent implements OnInit, OnDestroy {
5959

6060
private subscription = new Subscription();
6161
private unsubscribe: Subject<void> = new Subject();
62-
62+
public readonly USER_FONCTION_LABELS = USER_FONCTION_LABELS;
6363
public get f(): { [key: string]: AbstractControl } {
6464
return this.userForm.controls;
6565
}

packages/frontend/src/app/modules/manage-users/components/user-profil/user-profil.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ <h2>Utilisateurs enregistrés: {{ users.length }} utilisateurs</h2>
119119
</select>
120120
</ng-container>
121121
</td>
122-
<td>{{ user.fonction }}</td>
122+
<td>{{ USER_FONCTION_LABELS[user.fonction] }}</td>
123123
<td *ngIf="me.role === 'admin'">
124124
<button
125125
type="button"

packages/frontend/src/app/modules/manage-users/components/user-profil/user-profil.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
UserStructure,
2121
UserStructureRole,
2222
USER_STRUCTURE_ROLES_LABELS,
23+
USER_FONCTION_LABELS,
2324
} from "@domifa/common";
2425
import { ManageUsersService } from "../../services/manage-users.service";
2526

@@ -42,6 +43,7 @@ export class UserProfilComponent implements OnInit, OnDestroy {
4243
public expectedRole: UserStructureRole | null = null;
4344

4445
public readonly USER_STRUCTURE_ROLES_LABELS = USER_STRUCTURE_ROLES_LABELS;
46+
public readonly USER_FONCTION_LABELS = USER_FONCTION_LABELS;
4547

4648
@ViewChild("deleteUserConfirmation", { static: true })
4749
public deleteUserConfirmation!: TemplateRef<NgbModalRef>;

0 commit comments

Comments
 (0)