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

#2504 - ajustement visuels pour la liste d'agence d'un utilisateur. Colonnes "Actions" visible uniquement pour les admin IF. #2581

Merged
Merged
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
112 changes: 65 additions & 47 deletions front/src/app/components/UserDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ export const UserDetail = ({
agencyRights={[...userWithRights.agencyRights].sort((a, b) =>
a.agency.name.localeCompare(b.agency.name),
)}
isAdmin={userWithRights.isBackofficeAdmin}
/>
</div>
);
};

const AgenciesTable = ({ agencyRights }: { agencyRights: AgencyRight[] }) => {
const AgenciesTable = ({
agencyRights,
isAdmin,
}: {
agencyRights: AgencyRight[];
isAdmin?: boolean;
}) => {
if (!agencyRights.length)
return <p>Cet utilisateur n'est lié à aucune agence</p>;

Expand All @@ -78,56 +85,67 @@ const AgenciesTable = ({ agencyRights }: { agencyRights: AgencyRight[] }) => {
"Carractéristiques de l'agence",
"Roles",
"Reçoit les notifications",
"Actions",
...(isAdmin ? ["Actions"] : []),
]}
data={agencyRights.map((agencyRight) => {
const viewAgencyProps = !agencyRight.roles.includes("agency-admin")
? {
disabled: true,
title:
"Vous n'êtes pas administrateur de cette agence. Seuls les administrateurs de l'agence peuvent voir le détail.",
}
: {
linkProps: routes.adminAgencyDetail({
agencyId: agencyRight.agency.id,
}).link,
};
data={agencyRights.map((agencyRight) => [
<>
{agencyRight.agency.name}
<span className={fr.cx("fr-hint-text")}>
{addressDtoToString(agencyRight.agency.address)}
</span>

return [
<>
{agencyRight.agency.name}
<span className={fr.cx("fr-hint-text")}>
{addressDtoToString(agencyRight.agency.address)}
</span>
</>,
<ul className={fr.cx("fr-raw-list")}>
<li>
<AgencyTag
refersToAgencyName={agencyRight.agency.refersToAgencyName}
/>
</li>
{!activeAgencyStatuses.includes(agencyRight.agency.status) && (
<li>
<AgencyStatusBadge status={agencyRight.agency.status} />
</li>
)}
{agencyRight.roles.includes("agency-admin") && isAdmin && (
<a
className={fr.cx(
"fr-link",
"fr-text--sm",
"fr-icon-arrow-right-line",
"fr-link--icon-right",
)}
{...routes.adminAgencyDetail({
// this should be changed to agencyDashboardAgency/:agencyId, when it is ready
agencyId: agencyRight.agency.id,
}).link}
>
Voir l'agence
</a>
)}
</>,
<ul className={fr.cx("fr-raw-list")}>
<li>
<AgencyTag
refersToAgencyName={agencyRight.agency.refersToAgencyName}
/>
</li>
{!activeAgencyStatuses.includes(agencyRight.agency.status) && (
<li>
Type : {agencyKindToLabelIncludingIF[agencyRight.agency.kind]}
<AgencyStatusBadge status={agencyRight.agency.status} />
</li>
</ul>,
agencyRight.roles
.map((role) => agencyRoleToDisplay[role].label)
.join(", "),
agencyRight.isNotifiedByEmail ? "Oui" : "Non",
<Button
priority="tertiary no outline"
size="small"
{...viewAgencyProps}
>
Voir l'agence
</Button>,
];
})}
)}
<li>
Type : {agencyKindToLabelIncludingIF[agencyRight.agency.kind]}
</li>
</ul>,
agencyRight.roles
.map((role) => agencyRoleToDisplay[role].label)
.join(", "),
agencyRight.isNotifiedByEmail ? "Oui" : "Non",
...(isAdmin
? [
<Button
priority="tertiary no outline"
size="small"
linkProps={
routes.adminAgencyDetail({
agencyId: agencyRight.agency.id,
}).link
}
>
Voir l'agence comme admin IF
</Button>,
]
: []),
])}
/>
</>
);
Expand Down
Loading