-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
Review app: |
20b1171
to
1ca6367
Compare
1ca6367
to
606dc13
Compare
606dc13
to
babbbaa
Compare
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(), | ||
); | ||
}; |
There was a problem hiding this comment.
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...
const getEmailsFromUsersWithAgencyRoles = ( | ||
usersWithAgencyRole: UserWithAgencyRole[], | ||
{ agencyIdToMatch, roleToMatch }: AgencyMatchingCriteria, | ||
) => { | ||
return usersWithAgencyRole | ||
.filter( | ||
(user) => | ||
user.agencyId === agencyIdToMatch && user.roles.includes(roleToMatch), | ||
) | ||
.map((user) => user.email); | ||
}; |
There was a problem hiding this comment.
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
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())} | ||
/> | ||
</> | ||
); | ||
|
There was a problem hiding this comment.
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 ?
babbbaa
to
f141a9d
Compare
f141a9d
to
bf86efe
Compare
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.