Skip to content

Commit

Permalink
feat: check access rights
Browse files Browse the repository at this point in the history
  • Loading branch information
tonai committed Jan 30, 2025
1 parent 47167ee commit 100a8fd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions assets/entrepot/pages/dashboard/DashboardPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import avatarSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/digital
import mailSendSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/digital/mail-send.svg";
import humanCoopSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/environment/human-cooperation.svg";
import padlockSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/system/padlock.svg";
import { CommunityMemberDtoRightsEnum } from "../../../@types/entrepot";

const DashboardPro = () => {
const { t } = useTranslation("DashboardPro");
Expand All @@ -32,7 +33,8 @@ const DashboardPro = () => {
const setUser = useAuthStore((state) => state.setUser);
const isApiEspaceCoDefined = useApiEspaceCoStore((state) => state.isUrlDefined);

const configDatastore = user?.communities_member?.find((community) => community.community?.datastore === api.alerts.datastoreId)?.community;
const configDatastore = user?.communities_member?.find((community) => community.community?.datastore === api.alerts.datastoreId);
const canShowConfig = configDatastore?.rights?.includes(CommunityMemberDtoRightsEnum.ANNEX);

const userQuery = useQuery<CartesUser, CartesApiException>({
queryKey: RQKeys.user_me(),
Expand Down Expand Up @@ -183,10 +185,10 @@ const DashboardPro = () => {
</div>
</div>

{configDatastore && (
{canShowConfig && (
<>
<h2>{t("configuration")}</h2>
<div key={configDatastore.datastore} className={fr.cx("fr-col-12", "fr-col-sm-6", "fr-col-md-4", "fr-col-lg-3")}>
<div key={configDatastore?.community?.datastore} className={fr.cx("fr-col-12", "fr-col-sm-6", "fr-col-md-4", "fr-col-lg-3")}>
<Tile linkProps={routes.config_alerts().link} grey={true} title={t("alerts")} />
</div>
</>
Expand Down

0 comments on commit 100a8fd

Please sign in to comment.