Skip to content

Commit

Permalink
refactor createUserOnAgencyEpic after review
Browse files Browse the repository at this point in the history
  • Loading branch information
celineung committed Sep 9, 2024
1 parent 66d7599 commit 6aa6c32
Showing 1 changed file with 14 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,36 +132,20 @@ const createUserOnAgencyEpic: IcUsersAdminActionEpic = (
adminGateway
.createUserForAgency$(action.payload, getAdminToken(state$.value))
.pipe(
map(
({
id,
email,
firstName,
lastName,
createdAt,
dashboards,
externalId,
agencyRights,
}) =>
icUsersAdminSlice.actions.createUserOnAgencySucceeded({
icUser: {
id,
email,
firstName,
lastName,
externalId,
createdAt,
dashboards,
agencyRights: agencyRights.reduce(
(agenciesAcc, agencyRight) => ({
...agenciesAcc,
[agencyRight.agency.id]: agencyRight,
}),
{} as Record<AgencyId, AgencyRight>,
),
},
feedbackTopic: action.payload.feedbackTopic,
}),
map((user) =>
icUsersAdminSlice.actions.createUserOnAgencySucceeded({
icUser: {
...user,
agencyRights: user.agencyRights.reduce(
(agenciesAcc, agencyRight) => ({
...agenciesAcc,
[agencyRight.agency.id]: agencyRight,
}),
{} as Record<AgencyId, AgencyRight>,
),
},
feedbackTopic: action.payload.feedbackTopic,
}),
),
catchEpicError((error) =>
icUsersAdminSlice.actions.createUserOnAgencyFailed({
Expand Down

0 comments on commit 6aa6c32

Please sign in to comment.