Skip to content

Commit

Permalink
chore(admin-react): remove LEGAL_INFORMATION_VALIDATION flag and lega…
Browse files Browse the repository at this point in the history
…cy code
  • Loading branch information
cedricss committed Jul 2, 2024
1 parent f3ad6ac commit c88a55f
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 398 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import Alert from "@codegouvfr/react-dsfr/Alert";
import Input from "@codegouvfr/react-dsfr/Input";
import { useLegalInformationsPage } from "./legalInformationsPage.hook";
import { useFeatureflipping } from "@/components/feature-flipping/featureFlipping";
import { useAuth } from "@/components/auth/auth";
import { LegalInformationUpdateBlock } from "@/app/(aap)/agencies-settings/legal-information/_components/legal-information-update-block/LegalInformationUpdateBlock";
import { GrayCard } from "@/components/card/gray-card/GrayCard";

const LegalInformationPage = () => {
const { maisonMereAAP, legalInformationsStatus } = useLegalInformationsPage();
const { isGestionnaireMaisonMereAAP } = useAuth();
const { isFeatureActive } = useFeatureflipping();
return (
<div className="flex flex-col w-full">
<h1>Informations juridiques</h1>
Expand Down Expand Up @@ -80,22 +78,20 @@ const LegalInformationPage = () => {
</GrayCard>
</>
)}
{isFeatureActive("LEGAL_INFORMATION_VALIDATION") &&
isGestionnaireMaisonMereAAP &&
maisonMereAAP && (
<LegalInformationUpdateBlock
maisonMereAAPId={maisonMereAAP.id}
statutValidationInformationsJuridiquesMaisonMereAAP={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP
}
decisions={maisonMereAAP.legalInformationDocumentsDecisions.map(
(d) => ({
...d,
decisionTakenAt: new Date(d.decisionTakenAt),
}),
)}
/>
)}
{isGestionnaireMaisonMereAAP && maisonMereAAP && (
<LegalInformationUpdateBlock
maisonMereAAPId={maisonMereAAP.id}
statutValidationInformationsJuridiquesMaisonMereAAP={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP
}
decisions={maisonMereAAP.legalInformationDocumentsDecisions.map(
(d) => ({
...d,
decisionTakenAt: new Date(d.decisionTakenAt),
}),
)}
/>
)}
</>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
"use client";
import { useGraphQlClient } from "@/components/graphql/graphql-client/GraphqlClient";
import {
OrganismSummary,
Typology,
} from "@/components/organism-summary/OrganismSummary";

import { Typology as TypologyOrganismSummaryNewLegal } from "@/components/organism-summary/OrganismSummaryNewLegal";

import { OrganismSummary as OrganismSummaryNewLegal } from "@/components/organism-summary/OrganismSummaryNewLegal";
import { Typology } from "@/components/organism-summary/OrganismSummary";
import { OrganismSummary } from "@/components/organism-summary/OrganismSummary";
import { graphql } from "@/graphql/generated";
import { useQuery } from "@tanstack/react-query";
import { useParams } from "next/navigation";
import { selectedDepartmentsToTreeSelectItems } from "@/utils";
import MaisonMereAAPForm from "@/app/(admin)/maisonMereAAPs/[maisonMereAAPId]/MaisonMereAAPForm";
import { sortRegionsByAlphabeticalOrderAndDOM } from "@/utils";
import { BackButton } from "@/components/back-button/BackButton";
import { GrayCard } from "@/components/card/gray-card/GrayCard";
import ValidationDecisionForm from "./(components)/ValidationDecisionForm";
import { useFeatureflipping } from "@/components/feature-flipping/featureFlipping";
import { Info } from "@/components/organism-summary/Info";
import { LegalDocumentList } from "@/components/legal-document-list/LegalDocumentList";

Expand Down Expand Up @@ -122,11 +114,6 @@ const MaisonMereAAPPage = () => {

const { graphqlClient } = useGraphQlClient();

const featureFlipping = useFeatureflipping();
const showLegalValidation = featureFlipping.isFeatureActive(
"LEGAL_INFORMATION_VALIDATION",
);

const { data: getMaisonMereAAPResponse, isLoading: isMaisonMereAAPLoading } =
useQuery({
queryKey: ["getMaisonMereAAP", maisonMereAAPId],
Expand Down Expand Up @@ -160,121 +147,69 @@ const MaisonMereAAPPage = () => {
return (
maisonMereAAP && (
<div className="flex flex-col flex-1 px-8 py-4">
{!showLegalValidation && (
<BackButton href="/subscriptions/validated">
Toutes les inscriptions
</BackButton>
)}
{showLegalValidation ? (
<OrganismSummaryNewLegal
companyName={maisonMereAAP.raisonSociale}
accountFirstname={maisonMereAAP.gestionnaire.firstname || ""}
accountLastname={maisonMereAAP.gestionnaire.lastname || ""}
accountEmail={maisonMereAAP.gestionnaire.email}
accountPhoneNumber={maisonMereAAP.phone || ""}
companyQualiopiCertificateExpiresAt={
new Date(maisonMereAAP.dateExpirationCertificationQualiopi || "")
}
companySiret={maisonMereAAP.siret}
companyLegalStatus={maisonMereAAP.statutJuridique}
companyWebsite={maisonMereAAP.siteWeb}
companyTypology={
maisonMereAAP.typologie as TypologyOrganismSummaryNewLegal
}
ccns={maisonMereAAP.maisonMereAAPOnConventionCollectives.map(
(c) => c.ccn.label,
)}
createdAt={new Date(maisonMereAAP.createdAt)}
companyManagerFirstname={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP ==
"A_JOUR"
? maisonMereAAP.managerFirstname || undefined
: maisonMereAAP.legalInformationDocuments?.managerFirstname
}
companyManagerLastname={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP ==
"A_JOUR"
? maisonMereAAP.managerLastname || undefined
: maisonMereAAP.legalInformationDocuments?.managerLastname
}
legalInformationDocumentsDecisions={maisonMereAAP.legalInformationDocumentsDecisions.map(
(d) => ({
...d,
aapUpdatedDocumentsAt: new Date(d.aapUpdatedDocumentsAt),
decisionTakenAt: new Date(d.decisionTakenAt),
}),
)}
statutValidationInformationsJuridiquesMaisonMereAAP={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP
}
/>
) : (
<OrganismSummary
companyName={maisonMereAAP.raisonSociale}
accountFirstname={maisonMereAAP.gestionnaire.firstname || ""}
accountLastname={maisonMereAAP.gestionnaire.lastname || ""}
accountEmail={maisonMereAAP.gestionnaire.email}
accountPhoneNumber={maisonMereAAP.phone || ""}
companyQualiopiCertificateExpiresAt={
new Date(maisonMereAAP.dateExpirationCertificationQualiopi || "")
}
companySiret={maisonMereAAP.siret}
companyLegalStatus={maisonMereAAP.statutJuridique}
companyWebsite={maisonMereAAP.siteWeb}
companyTypology={maisonMereAAP.typologie as Typology}
ccns={maisonMereAAP.maisonMereAAPOnConventionCollectives.map(
(c) => c.ccn.label,
)}
/>
)}

{showLegalValidation ? (
<GrayCard className="mt-8">
<h3>Agences</h3>
<ol className="grid grid-cols-1 md:grid-cols-2">
{maisonMereAAP.organisms.map((o) => (
<li key={o.id} className="ml-4">
<h3 className="text-lg font-bold">
{o.informationsCommerciales?.nom || o.label}
</h3>
<Info title="Fermée pour absence ou congés:">
<div> {o.fermePourAbsenceOuConges ? "Oui" : "Non"}</div>
</Info>
<Info title="Niveaux de diplômes couverts:">
<ul>
{o.managedDegrees.map((d) => (
<li key={d.id}>{d.degree.longLabel}</li>
))}
</ul>
</Info>
</li>
))}
</ol>
</GrayCard>
) : (
<GrayCard className="mt-8">
<h3>Agences</h3>
<ol>
{maisonMereAAP.organisms.map((o) => (
<li key={o.id} className="ml-4">
<h3 className="text-lg font-bold">
{o.informationsCommerciales?.nom || o.label}
</h3>
<Info title="Fermée pour absence ou congées:">
<div> {o.fermePourAbsenceOuConges ? "Oui" : "Non"}</div>
</Info>
<Info title="Niveaux de diplômes couverts:">
<ul>
{o.managedDegrees.map((d) => (
<li key={d.id}>{d.degree.longLabel}</li>
))}
</ul>
</Info>
</li>
))}
</ol>
</GrayCard>
)}
<OrganismSummary
companyName={maisonMereAAP.raisonSociale}
accountFirstname={maisonMereAAP.gestionnaire.firstname || ""}
accountLastname={maisonMereAAP.gestionnaire.lastname || ""}
accountEmail={maisonMereAAP.gestionnaire.email}
accountPhoneNumber={maisonMereAAP.phone || ""}
companyQualiopiCertificateExpiresAt={
new Date(maisonMereAAP.dateExpirationCertificationQualiopi || "")
}
companySiret={maisonMereAAP.siret}
companyLegalStatus={maisonMereAAP.statutJuridique}
companyWebsite={maisonMereAAP.siteWeb}
companyTypology={maisonMereAAP.typologie as Typology}
ccns={maisonMereAAP.maisonMereAAPOnConventionCollectives.map(
(c) => c.ccn.label,
)}
createdAt={new Date(maisonMereAAP.createdAt)}
companyManagerFirstname={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP ==
"A_JOUR"
? maisonMereAAP.managerFirstname || undefined
: maisonMereAAP.legalInformationDocuments?.managerFirstname
}
companyManagerLastname={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP ==
"A_JOUR"
? maisonMereAAP.managerLastname || undefined
: maisonMereAAP.legalInformationDocuments?.managerLastname
}
legalInformationDocumentsDecisions={maisonMereAAP.legalInformationDocumentsDecisions.map(
(d) => ({
...d,
aapUpdatedDocumentsAt: new Date(d.aapUpdatedDocumentsAt),
decisionTakenAt: new Date(d.decisionTakenAt),
}),
)}
statutValidationInformationsJuridiquesMaisonMereAAP={
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP
}
/>
)
<GrayCard className="mt-8">
<h3>Agences</h3>
<ol className="grid grid-cols-1 md:grid-cols-2">
{maisonMereAAP.organisms.map((o) => (
<li key={o.id} className="ml-4">
<h3 className="text-lg font-bold">
{o.informationsCommerciales?.nom || o.label}
</h3>
<Info title="Fermée pour absence ou congés:">
<div> {o.fermePourAbsenceOuConges ? "Oui" : "Non"}</div>
</Info>
<Info title="Niveaux de diplômes couverts:">
<ul>
{o.managedDegrees.map((d) => (
<li key={d.id}>{d.degree.longLabel}</li>
))}
</ul>
</Info>
</li>
))}
</ol>
</GrayCard>
<MaisonMereAAPForm
maisonMereAAPId={maisonMereAAP.id}
onSiteDepartmentsOnRegions={regions.map(
Expand All @@ -287,9 +222,8 @@ const MaisonMereAAPPage = () => {
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP
}
/>
{showLegalValidation &&
maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP ===
"EN_ATTENTE_DE_VERIFICATION" &&
{maisonMereAAP.statutValidationInformationsJuridiquesMaisonMereAAP ===
"EN_ATTENTE_DE_VERIFICATION" &&
maisonMereAAP.legalInformationDocuments && (
<>
<LegalDocumentList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { ReactNode, useCallback, useMemo } from "react";
import { SideMenu } from "@codegouvfr/react-dsfr/SideMenu";
import { usePathname, useSearchParams } from "next/navigation";
import { useFeatureflipping } from "@/components/feature-flipping/featureFlipping";
import { graphql } from "@/graphql/generated";
import { useQuery } from "@tanstack/react-query";
import { useGraphQlClient } from "@/components/graphql/graphql-client/GraphqlClient";
Expand Down Expand Up @@ -72,58 +71,42 @@ const SubscriptionsLayout = ({ children }: { children: ReactNode }) => {
[searchFilter],
);

const featureFlipping = useFeatureflipping();
const showLegalMenuItems = featureFlipping.isFeatureActive(
"LEGAL_INFORMATION_VALIDATION",
);

const items = useMemo(() => {
if (showLegalMenuItems) {
return [
menuItem(
"Inscriptions à vérifier",
hrefSideMenu("pending"),
currentPathname,
subscriptionCountByStatus?.PENDING_SUBSCRIPTION,
),
menuItem(
"Inscriptions refusées",
hrefSideMenu("rejected"),
currentPathname,
subscriptionCountByStatus?.REJECTED_SUBSCRIPTION,
),
const items = useMemo(
() => [
menuItem(
"Inscriptions à vérifier",
hrefSideMenu("pending"),
currentPathname,
subscriptionCountByStatus?.PENDING_SUBSCRIPTION,
),
menuItem(
"Inscriptions refusées",
hrefSideMenu("rejected"),
currentPathname,
subscriptionCountByStatus?.REJECTED_SUBSCRIPTION,
),

menuItem(
"Comptes administrateur à vérifier",
hrefSideMenu("check-legal-information"),
currentPathname,
subscriptionCountByStatus?.PENDING_LEGAL_VERIFICATION,
),
menuItem(
"Comptes administrateur incomplets",
hrefSideMenu("validated"),
currentPathname,
subscriptionCountByStatus?.NEED_LEGAL_VERIFICATION,
),
menuItem(
"Comptes administrateur vérifiés",
hrefSideMenu("up-to-date"),
currentPathname,
subscriptionCountByStatus?.APPROVED,
),
];
}
return [
menuItem("En attente", hrefSideMenu("pending"), currentPathname),
menuItem("Validées", hrefSideMenu("validated"), currentPathname),
menuItem("Refusées", hrefSideMenu("rejected"), currentPathname),
];
}, [
showLegalMenuItems,
subscriptionCountByStatus,
currentPathname,
hrefSideMenu,
]);
menuItem(
"Comptes administrateur à vérifier",
hrefSideMenu("check-legal-information"),
currentPathname,
subscriptionCountByStatus?.PENDING_LEGAL_VERIFICATION,
),
menuItem(
"Comptes administrateur incomplets",
hrefSideMenu("validated"),
currentPathname,
subscriptionCountByStatus?.NEED_LEGAL_VERIFICATION,
),
menuItem(
"Comptes administrateur vérifiés",
hrefSideMenu("up-to-date"),
currentPathname,
subscriptionCountByStatus?.APPROVED,
),
],
[subscriptionCountByStatus, currentPathname, hrefSideMenu],
);

return (
<div className="flex flex-col flex-1 md:flex-row gap-10 md:gap-0">
Expand Down
Loading

0 comments on commit c88a55f

Please sign in to comment.