Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collectivite confidentielle #3198

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app.territoiresentransitions.react/src/app/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ type Props = {
const Layout = ({children}: Props) => {
return (
<div className="flex flex-col h-[100vh] overflow-hidden">
<div id="main" className="w-full overflow-x-hidden overflow-y-auto">
<div
id="main"
className="flex-grow flex flex-col w-full overflow-x-hidden overflow-y-auto"
>
<Header />
{children}
<Footer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`Storyshots app/Layout Exemple 1`] = `
className="flex flex-col h-[100vh] overflow-hidden"
>
<div
className="w-full overflow-x-hidden overflow-y-auto"
className="flex-grow flex flex-col w-full overflow-x-hidden overflow-y-auto"
id="main"
>
<header
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
import {ReactNode} from 'react';
import {referentielToName} from 'app/labels';
import {useCollectiviteId} from 'core-logic/hooks/params';
import {useProgressionReferentiel} from './data/useProgressionReferentiel';
import EtatDesLieux from './EtatDesLieux/EtatDesLieux';
import IndicateursCard from './IndicateursCard';
import PlansActionCard from './PlansActionCard';
import {useCurrentCollectivite} from 'core-logic/hooks/useCurrentCollectivite';
import {useAuth} from 'core-logic/api/auth/AuthProvider';

/**
* Affiche la page d'accueil d'une collectivité
*/
const Accueil = (): JSX.Element => {
const collectiviteId = useCollectiviteId();
const collectivite = useCurrentCollectivite();

const {user} = useAuth();

if (!collectivite?.collectivite_id) return <></>;

/** Vérifi que l'utilisateur peut accéder à la collectivité */
const hasNoAccessToCollectivite =
collectivite.acces_restreint &&
collectivite.niveau_acces === null &&
!user?.isSupport &&
!collectivite.est_auditeur;

/** S'il ne peut pas, on affiche un message */
if (hasNoAccessToCollectivite) {
return (
<div className="flex-grow flex">
<div className="m-auto text-grey-7">
Cette collectivité n’est pas accessible en mode visite.
</div>
</div>
);
}

/** Sinon on affiche la page.
* Ceci permet de ne pas appeler `useProgressionReferentiel`
* qui ne marche pas si l'utilisateur n'a pas les droits */
return (
<AccueilNonConfidentielle collectiviteId={collectivite.collectivite_id} />
);
};

/** Affiche le tableau de bord de l'accueil pour les utilisateurs avec les droits nécessaires */
const AccueilNonConfidentielle = ({
collectiviteId,
}: {
collectiviteId: number;
}) => {
const {
caeTable: caeProgressionScore,
eciTable: eciProgressionScore,
Expand All @@ -19,7 +57,6 @@ const Accueil = (): JSX.Element => {
caePotentiel,
eciPotentiel,
} = useProgressionReferentiel();

return (
<main data-test="TableauBord" className="bg-bf975 -mb-8">
{!!collectiviteId && (
Expand Down
Loading