From 3c3ea151d2c098fda8e9b86c5c5e69e59c1ab272 Mon Sep 17 00:00:00 2001 From: Yassine R Date: Thu, 26 Oct 2023 18:07:06 +0200 Subject: [PATCH] fix(profil): add link to check user profile --- .../src/_common/model/usager/Usager.type.ts | 1 - .../_common/model/usager/UsagerLight.type.ts | 1 - .../manage-usagers-table.component.ts | 5 +- .../manage-usagers-table.html | 8 +- .../step-decision/step-decision.component.ts | 4 +- .../step-documents.component.html | 6 - .../step-entretien.component.html | 6 - .../step-etat-civil.component.html | 7 - .../step-footer/step-footer.component.html | 7 + .../step-header/step-header.component.html | 38 +++-- .../step-rdv/step-rdv.component.html | 6 - .../delete-usager-menu.component.html | 135 ++++++++---------- .../delete-usager-menu.component.spec.ts | 2 - .../delete-usager-menu.component.ts | 55 +++---- .../delete-usager/delete-usager.component.ts | 10 +- .../interfaces/UsagerFormModel.ts | 7 +- .../utils/getUrlUsagerProfil.service.spec.ts | 11 +- .../utils/getUrlUsagerProfil.service.ts | 12 +- .../app/shared/store/ngRxAppStore.service.ts | 2 - 19 files changed, 148 insertions(+), 175 deletions(-) diff --git a/packages/frontend/src/_common/model/usager/Usager.type.ts b/packages/frontend/src/_common/model/usager/Usager.type.ts index 8b6786cee0..48d4d31caa 100644 --- a/packages/frontend/src/_common/model/usager/Usager.type.ts +++ b/packages/frontend/src/_common/model/usager/Usager.type.ts @@ -69,6 +69,5 @@ export type Usager = AppEntity & { // Variables de front echeanceInfos?: UsagerEcheanceInfos; rdvInfos?: UsagerRdvInfos; - usagerProfilUrl?: string; nbNotes?: number; }; diff --git a/packages/frontend/src/_common/model/usager/UsagerLight.type.ts b/packages/frontend/src/_common/model/usager/UsagerLight.type.ts index f61f6ced3c..1dc09c5193 100644 --- a/packages/frontend/src/_common/model/usager/UsagerLight.type.ts +++ b/packages/frontend/src/_common/model/usager/UsagerLight.type.ts @@ -29,7 +29,6 @@ export type UsagerLight = AppEntity & | "langue" | "contactByPhone" | "import" - | "usagerProfilUrl" | "echeanceInfos" | "rdvInfos" | "pinnedNote" diff --git a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts index bdda1b7590..4e8495b5ea 100644 --- a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts +++ b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts @@ -13,6 +13,7 @@ import { NgbModal, NgbModalRef } from "@ng-bootstrap/ng-bootstrap"; import { DEFAULT_MODAL_OPTIONS, + ETAPES_DEMANDE_URL, UserStructure, } from "../../../../../_common/model"; import { fadeInOut } from "../../../../shared"; @@ -24,6 +25,7 @@ import { } from "../usager-filter"; import { Router } from "@angular/router"; import { AuthService } from "../../../shared/services"; +import { getUrlUsagerProfil } from "../../../usager-shared/utils"; @Component({ animations: [fadeInOut], @@ -59,6 +61,7 @@ export class ManageUsagersTableComponent implements OnDestroy { }>(); public me!: UserStructure | null; private subscription = new Subscription(); + public readonly ETAPES_DEMANDE_URL = ETAPES_DEMANDE_URL; constructor( private readonly modalService: NgbModal, @@ -85,7 +88,7 @@ export class ManageUsagersTableComponent implements OnDestroy { } public goToProfil(usager: UsagerFormModel): void { - this.router.navigate([usager.usagerProfilUrl]); + this.router.navigate([getUrlUsagerProfil(usager)]); } public refTrackBy(_index: number, item: UsagerFormModel) { diff --git a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html index d9abad9625..f51105bb79 100644 --- a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html +++ b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html @@ -180,7 +180,13 @@ > - + Consulter la fiche de {{ usager.nom | uppercase }} {{ usager.prenom }} diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-decision/step-decision.component.ts b/packages/frontend/src/app/modules/usager-dossier/components/step-decision/step-decision.component.ts index f1052bc770..60cea3d762 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-decision/step-decision.component.ts +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-decision/step-decision.component.ts @@ -77,10 +77,10 @@ export class StepDecisionComponent public setDecisionAttente() { this.subscription.add( this.usagerDecisionService - .setDecision(this.usager.ref, { statut: "ATTENTE_DECISION" }) + .setDecision(this.usager.ref, { statut: "ATTENTE_DECISION" }, true) .subscribe({ next: () => { - this.toastService.success("Décision enregistrée avec succès ! "); + this.toastService.success("Décision enregistrée avec succès !"); }, error: () => { this.toastService.error("La décision n'a pas pu être enregistrée"); diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-documents/step-documents.component.html b/packages/frontend/src/app/modules/usager-dossier/components/step-documents/step-documents.component.html index 30bdefed69..be30f67115 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-documents/step-documents.component.html +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-documents/step-documents.component.html @@ -59,11 +59,5 @@

Pièces justificatives complétant le dossier

- - diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-entretien/step-entretien.component.html b/packages/frontend/src/app/modules/usager-dossier/components/step-entretien/step-entretien.component.html index 73a047962e..8cff6d4b02 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-entretien/step-entretien.component.html +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-entretien/step-entretien.component.html @@ -15,10 +15,4 @@ - - diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-etat-civil/step-etat-civil.component.html b/packages/frontend/src/app/modules/usager-dossier/components/step-etat-civil/step-etat-civil.component.html index f7468d218e..99ab23564e 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-etat-civil/step-etat-civil.component.html +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-etat-civil/step-etat-civil.component.html @@ -729,11 +729,4 @@

État civil du demandeur

- - diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-footer/step-footer.component.html b/packages/frontend/src/app/modules/usager-dossier/components/step-footer/step-footer.component.html index b71936f697..43b177ee99 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-footer/step-footer.component.html +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-footer/step-footer.component.html @@ -4,3 +4,10 @@

Commentaires privés

+ + diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-header/step-header.component.html b/packages/frontend/src/app/modules/usager-dossier/components/step-header/step-header.component.html index 944fd2350d..15a2e151e5 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-header/step-header.component.html +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-header/step-header.component.html @@ -29,20 +29,30 @@

-
-
- Commentaires privés -
- {{ nbNotes }} -
-
+
+ + Voir le dossier complet + + +
+ Commentaires privés +
+ {{ nbNotes }} +
+
+
diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html b/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html index aca603917b..bb7e4403a6 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html @@ -323,11 +323,5 @@

- - diff --git a/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.html b/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.html index 7ee13ed97a..a4a8a692af 100644 --- a/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.html +++ b/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.html @@ -1,98 +1,77 @@ - -
-
- - - - - - - - - - - -
+
+
+
- +
- +
+
+ + + - - @@ -128,6 +107,6 @@ diff --git a/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.spec.ts b/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.spec.ts index aa12079a61..be2a3eb16b 100644 --- a/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.spec.ts +++ b/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.spec.ts @@ -1,4 +1,3 @@ -import { USER_STRUCTURE_MOCK } from "./../../../../../_common/mocks/USER_STRUCTURE.mock"; import { USAGER_ACTIF_MOCK } from "./../../../../../_common/mocks/USAGER_ACTIF.mock"; import { ComponentFixture, TestBed } from "@angular/core/testing"; import { NO_ERRORS_SCHEMA } from "@angular/core"; @@ -34,7 +33,6 @@ describe("DeleteUsagerMenuComponent", () => { fixture = TestBed.createComponent(DeleteUsagerMenuComponent); component = fixture.debugElement.componentInstance; component.usager = new UsagerFormModel(USAGER_ACTIF_MOCK); - component.me = USER_STRUCTURE_MOCK; component.ngOnInit(); }); diff --git a/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.ts b/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.ts index 6e8ec5d1e6..100ebda91b 100644 --- a/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.ts +++ b/packages/frontend/src/app/modules/usager-shared/components/delete-usager-menu/delete-usager-menu.component.ts @@ -11,14 +11,19 @@ import { NgbModal, NgbModalRef } from "@ng-bootstrap/ng-bootstrap"; import { DEFAULT_MODAL_OPTIONS, - UserStructure, + UsagerLight, } from "../../../../../_common/model"; import { CustomToastService } from "../../../shared/services/custom-toast.service"; import { UsagerDecisionService } from "../../services/usager-decision.service"; import { Decision } from "../../interfaces"; import { Subscription } from "rxjs"; -import { USAGER_DECISION_STATUT_LABELS } from "@domifa/common"; +import { + USAGER_DECISION_STATUT_LABELS, + UsagerDecisionStatut, +} from "@domifa/common"; +import { getUrlUsagerProfil } from "../../utils"; +import { AuthService } from "../../../shared/services"; @Component({ styleUrls: ["./delete-usager-menu.component.css"], @@ -27,33 +32,40 @@ import { USAGER_DECISION_STATUT_LABELS } from "@domifa/common"; }) export class DeleteUsagerMenuComponent implements OnInit, OnDestroy { @Input() public usager!: UsagerFormModel; - @Input() public context!: "HISTORY" | "PROFIL"; - @Input() public me!: UserStructure; + @Input() public context!: "HISTORY" | "PROFIL" | "INSTRUCTION_FORM"; private subscription = new Subscription(); - public isFirstInstruction: boolean; + public previousStatus: string; public loading: boolean; public isAdmin: boolean; + public readonly DECISION_LABELS: { + [key in UsagerDecisionStatut]: string; + } = { + VALIDE: "Domiciliation acceptée", + INSTRUCTION: "Instruction du dossier", + ATTENTE_DECISION: "Dossier mis en attente de décision", + REFUS: "Dossier refusé", + RADIE: "Dossier radié", + }; + constructor( private readonly router: Router, private readonly modalService: NgbModal, private readonly usagerDecisionService: UsagerDecisionService, - private readonly toastService: CustomToastService + private readonly toastService: CustomToastService, + private readonly authService: AuthService ) { this.isAdmin = false; this.loading = false; - this.isFirstInstruction = false; + this.previousStatus = ""; } public ngOnInit(): void { - this.isAdmin = this.me?.role === "admin" || this.me?.role === "responsable"; - - const hasOneHistorique = this.usager.historique.length === 1; - this.isFirstInstruction = - hasOneHistorique && this.usager.decision.statut === "INSTRUCTION"; + const user = this.authService.currentUserValue; + this.isAdmin = user?.role === "admin" || user?.role === "responsable"; if (this.usager.historique.length > 1) { this.getPreviousStatus(); @@ -81,28 +93,19 @@ export class DeleteUsagerMenuComponent implements OnInit, OnDestroy { this.loading = true; this.subscription.add( this.usagerDecisionService.deleteDecision(this.usager.ref).subscribe({ - next: () => { - this.toastService.success( - "Demande de renouvellement supprimée avec succès" - ); - + next: (newUsager: UsagerLight) => { + this.toastService.success("Décision supprimée avec succès"); + this.modalService.dismissAll(); setTimeout(() => { - this.modalService.dismissAll(); this.loading = false; - - const redirection = - this.usager.decision.statut === "INSTRUCTION" || - this.usager.decision.statut === "ATTENTE_DECISION" - ? "usager/" + this.usager.ref + "/edit/decision" - : "profil/general/" + this.usager.ref; - + const redirection = getUrlUsagerProfil(newUsager); this.router.navigate([redirection]); }, 500); }, error: () => { this.loading = false; this.toastService.error( - "La demande de renouvellement n'a pas pu être supprimée" + "La demande décision n'a pas pu être supprimée" ); }, }) diff --git a/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.ts b/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.ts index 8cdb5b8f12..37971307ac 100644 --- a/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.ts +++ b/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.ts @@ -6,6 +6,7 @@ import { CustomToastService } from "../../../shared/services"; import { UsagerProfilService } from "../../../usager-profil/services/usager-profil.service"; import { Store } from "@ngrx/store"; import { cacheManager } from "../../../../shared"; +import { Router } from "@angular/router"; @Component({ selector: "app-delete-usager", @@ -25,7 +26,8 @@ export class DeleteUsagerComponent implements OnDestroy { private readonly modalService: NgbModal, private readonly usagerProfilService: UsagerProfilService, private readonly toastService: CustomToastService, - private readonly store: Store + private readonly store: Store, + private readonly router: Router ) { this.loading = false; this.selectedRefs = []; @@ -45,12 +47,16 @@ export class DeleteUsagerComponent implements OnDestroy { const message = this.selectedRefs.length > 1 ? "Les dossiers sélectionnés ont été supprimé avec succès" - : "Usager supprimé avec succès"; + : "Domicilié supprimé avec succès"; this.toastService.success(message); this.loading = false; this.store.dispatch( cacheManager.deleteUsagers({ usagerRefs: this.selectedRefs }) ); + + if (this.context === "PROFIL") { + this.router.navigate(["/manage"]); + } this.modalService.dismissAll(); }, error: () => { diff --git a/packages/frontend/src/app/modules/usager-shared/interfaces/UsagerFormModel.ts b/packages/frontend/src/app/modules/usager-shared/interfaces/UsagerFormModel.ts index e6af487d24..7b21ae4512 100644 --- a/packages/frontend/src/app/modules/usager-shared/interfaces/UsagerFormModel.ts +++ b/packages/frontend/src/app/modules/usager-shared/interfaces/UsagerFormModel.ts @@ -10,7 +10,7 @@ import { UsagerLight, } from "../../../../_common/model"; -import { getEcheanceInfos, getRdvInfos, getUrlUsagerProfil } from "../utils"; +import { getEcheanceInfos, getRdvInfos } from "../utils"; import { ETAPE_ETAT_CIVIL, USAGER_DECISION_STATUT_COLORS, @@ -76,10 +76,6 @@ export class UsagerFormModel { public nbNotes?: number = 0; - // Dates à afficher sur le manage, couleur selon le statut - // UNiquement pour la recherche - public usagerProfilUrl: string; - constructor(usager?: UsagerLight) { this.pinnedNote = usager?.pinnedNote || null; this.ref = usager?.ref || 0; @@ -141,7 +137,6 @@ export class UsagerFormModel { }; this.echeanceInfos = getEcheanceInfos(usager); this.rdvInfos = getRdvInfos(usager); - this.usagerProfilUrl = getUrlUsagerProfil(usager); this.totalInteractionsEnAttente = 0; INTERACTIONS_IN_AVAILABLE.forEach((interaction) => { this.totalInteractionsEnAttente += this.lastInteraction[interaction]; diff --git a/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.spec.ts b/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.spec.ts index 918fd06356..6f16166b6a 100644 --- a/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.spec.ts +++ b/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.spec.ts @@ -17,21 +17,14 @@ it("getUrlUsagerProfil: redirection vers le profil", () => { USAGER_ACTIF_MOCK.decision.statut = "RADIE"; expect(getUrlUsagerProfil(USAGER_ACTIF_MOCK)).toEqual("/profil/general/5"); - // Attente décision = page de décision - USAGER_ACTIF_MOCK.decision.statut = "ATTENTE_DECISION"; - expect(getUrlUsagerProfil(USAGER_ACTIF_MOCK)).toEqual("/profil/general/5"); - - // Renouvellement + instruction = retour à la page profil - USAGER_ACTIF_MOCK.decision.statut = "INSTRUCTION"; - expect(getUrlUsagerProfil(USAGER_ACTIF_MOCK)).toEqual("/profil/general/5"); - // Premiere demande + instruction = Aller sur le dossier d'instruction USAGER_ACTIF_MOCK.typeDom = "PREMIERE_DOM"; + USAGER_ACTIF_MOCK.decision.statut = "ATTENTE_DECISION"; USAGER_ACTIF_MOCK.etapeDemande = ETAPE_DOCUMENTS; expect(getUrlUsagerProfil(USAGER_ACTIF_MOCK)).toEqual( "/usager/5/edit/documents" ); - + USAGER_ACTIF_MOCK.decision.statut = "INSTRUCTION"; USAGER_ACTIF_MOCK.etapeDemande = ETAPE_ENTRETIEN; expect(getUrlUsagerProfil(USAGER_ACTIF_MOCK)).toEqual( "/usager/5/edit/entretien" diff --git a/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.ts b/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.ts index fb8da862dc..f1258755d2 100644 --- a/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.ts +++ b/packages/frontend/src/app/modules/usager-shared/utils/getUrlUsagerProfil.service.ts @@ -1,13 +1,15 @@ import { ETAPES_DEMANDE_URL, UsagerLight } from "../../../../_common/model"; +import { UsagerFormModel } from "../interfaces"; -export const getUrlUsagerProfil = (usager?: UsagerLight): string => { +export const getUrlUsagerProfil = ( + usager?: UsagerLight | UsagerFormModel +): string => { if (!usager?.decision) { return "/usager/nouveau"; } - - const { decision, ref, typeDom, etapeDemande } = usager; - - return decision.statut === "INSTRUCTION" && typeDom !== "RENOUVELLEMENT" + const { decision, ref, etapeDemande } = usager; + return decision.statut === "INSTRUCTION" || + decision.statut === "ATTENTE_DECISION" ? `/usager/${ref}/edit/${ETAPES_DEMANDE_URL[etapeDemande]}` : `/profil/general/${ref}`; }; diff --git a/packages/frontend/src/app/shared/store/ngRxAppStore.service.ts b/packages/frontend/src/app/shared/store/ngRxAppStore.service.ts index b950ce4d8a..7a4386621e 100644 --- a/packages/frontend/src/app/shared/store/ngRxAppStore.service.ts +++ b/packages/frontend/src/app/shared/store/ngRxAppStore.service.ts @@ -10,7 +10,6 @@ import { import { getEcheanceInfos, getRdvInfos, - getUrlUsagerProfil, } from "../../modules/usager-shared/utils"; import { Options, @@ -232,7 +231,6 @@ export const setUsagerInformations = (usager: UsagerLight): any => { }, echeanceInfos: getEcheanceInfos(usager), rdvInfos: getRdvInfos(usager), - usagerProfilUrl: getUrlUsagerProfil(usager), totalInteractionsEnAttente, historique: [], options: new Options(usager.options),