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

#2640 - Profil utilisateur : liste des agences en revue #2795

Merged
merged 5 commits into from
Jan 13, 2025

Conversation

bbohec
Copy link
Contributor

@bbohec bbohec commented Jan 9, 2025

Ca inclus ajout des mails des admin d'agence dans le DTO des droits d'agence des utilisateurs.
Il y a aussi quelques éléments de refacto.

image

@bbohec bbohec self-assigned this Jan 9, 2025
@bbohec bbohec changed the title #2640 - Profile utilisateur la liste des agences en revue #2640 - Profile utilisateur: liste des agences en revue Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

@bbohec bbohec force-pushed the 2640-user-profile-agencies-to-review branch from 20b1171 to 1ca6367 Compare January 10, 2025 12:20
@bbohec bbohec force-pushed the 2640-user-profile-agencies-to-review branch from 1ca6367 to 606dc13 Compare January 10, 2025 15:51
@bbohec bbohec force-pushed the 2640-user-profile-agencies-to-review branch from 606dc13 to babbbaa Compare January 10, 2025 17:01
@enguerranws enguerranws changed the title #2640 - Profile utilisateur: liste des agences en revue #2640 - Profil utilisateur: liste des agences en revue Jan 13, 2025
@enguerranws enguerranws changed the title #2640 - Profil utilisateur: liste des agences en revue #2640 - Profil utilisateur : liste des agences en revue Jan 13, 2025
Comment on lines +358 to +390
const getUsersWithAgencyRole = async (
transaction: KyselyDb,
{
agencyIds,
isNotifiedByEmail,
}: {
agencyIds: AgencyId[];
isNotifiedByEmail?: boolean;
},
): Promise<UserWithAgencyRole[]> => {
if (agencyIds.length === 0) return [];

return pipeWithValue(
transaction
.selectFrom("users__agencies")
.innerJoin("users", "users.id", "users__agencies.user_id")
.where("agency_id", "in", agencyIds)
.orderBy("users.email")
.select([
"users.id as userId",
"users.email",
sql<AgencyRole[]>`users__agencies.roles`.as("roles"),
"users__agencies.agency_id as agencyId",
"users__agencies.is_notified_by_email as isNotifiedByEmail",
]),
(builder) => {
if (isNotifiedByEmail !== undefined)
return builder.where("is_notified_by_email", "=", isNotifiedByEmail);
return builder;
},
(builder) => builder.execute(),
);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cette fonction n'est pas exporté et pas utilisé on dirait...

Comment on lines +397 to +407
const getEmailsFromUsersWithAgencyRoles = (
usersWithAgencyRole: UserWithAgencyRole[],
{ agencyIdToMatch, roleToMatch }: AgencyMatchingCriteria,
) => {
return usersWithAgencyRole
.filter(
(user) =>
user.agencyId === agencyIdToMatch && user.roles.includes(roleToMatch),
)
.map((user) => user.email);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ici c'est pareil on dirait

Comment on lines 102 to 149
const ActiveAgencyRightsTable = ({
agenciesWithoutToReviewRights,
onUpdateClicked,
isBackofficeAdmin,
}: {
agenciesWithoutToReviewRights: AgencyRight[];
onUpdateClicked: (agencyRight: AgencyRight) => void;
isBackofficeAdmin?: boolean;
}) => (
<>
<h2 className={fr.cx("fr-h4")}>
Organismes rattachés au profil ({agenciesWithoutToReviewRights.length}{" "}
{agenciesWithoutToReviewRights.length === 1 ? "agence" : "agences"})
</h2>

<Table
headers={[
"Organisme",
"Caractéristiques de l'agence",
"Administrateurs",
"Roles",
"Reçoit les notifications",
"Actions",
]}
data={agenciesWithoutToReviewRights
.sort((a, b) => a.agency.name.localeCompare(b.agency.name))
.map(makeAgencyRightLine(onUpdateClicked, isBackofficeAdmin))}
/>
</>
);

const OnGoingAgencyRightsTable = ({
agenciesWithToReviewRights,
}: { agenciesWithToReviewRights: AgencyRight[] }) => (
<>
<h2 className={fr.cx("fr-h4")}>
Demandes d'accès en cours ({agenciesWithToReviewRights.length}{" "}
{agenciesWithToReviewRights.length === 1 ? "agence" : "agences"})
</h2>
<Table
headers={["Organisme", "Caractéristiques de l'agence", "Administrateurs"]}
data={agenciesWithToReviewRights
.sort((a, b) => a.agency.name.localeCompare(b.agency.name))
.map(makeAgencyWithToReviewRightLine())}
/>
</>
);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on peut peut-être éclater en plusieurs fichiers ? 

un pour ActiveAgencyRightsTable, OnGoingAgencyRightsTable et un pour ce qui est commun ? 

@bbohec bbohec force-pushed the 2640-user-profile-agencies-to-review branch from babbbaa to f141a9d Compare January 13, 2025 10:16
@bbohec bbohec force-pushed the 2640-user-profile-agencies-to-review branch from f141a9d to bf86efe Compare January 13, 2025 10:20
@bbohec bbohec merged commit 394fe24 into main Jan 13, 2025
12 checks passed
@bbohec bbohec deleted the 2640-user-profile-agencies-to-review branch January 13, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants