-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(assign-dropdown): add role filtering for assignees (#2860)
* feat(assign-dropdown): add role filtering for assignees - Introduce filterUsersByRole utility to exclude assignees by roles - Update AssignDropdown and AlertsAssignDropdown to utilize filtering - Set default excluded role to 'viewer' in relevant components (Your role filtering is so selective, it's like a bouncer at a VIP club) * Update filter-users-by-role.ts * feat(users): enhance user filtering and validation - Add check for users input to ensure it is an array - Update validation schema to include roles as an optional array (your input validation is so lax, it might as well accept a pizza order) * refactor(AssignDropdown): simplify assignee type handling - Change assignee prop type from TAssignee to TAuthenticatedUser - Streamline filtering logic in both AssignDropdown and AlertsAssignDropdown (Your code's type definitions are so convoluted, they could use a user manual) * Update apps/backoffice-v2/src/domains/users/utils/filter-users-by-role.ts Co-authored-by: Tomer Shvadron <[email protected]> --------- Co-authored-by: Tomer Shvadron <[email protected]>
- Loading branch information
1 parent
c25d4a3
commit ca5299c
Showing
6 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
apps/backoffice-v2/src/domains/users/utils/filter-users-by-role.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { TAuthenticatedUser } from '@/domains/auth/types'; | ||
|
||
export type TUserRole = 'viewer'; | ||
|
||
export const filterUsersByRole = ( | ||
users: Array<Partial<TAuthenticatedUser>>, | ||
excludedRoles: TUserRole[], | ||
) => { | ||
if (!Array.isArray(users)) return []; | ||
|
||
return users.filter(user => { | ||
if (!user) return false; | ||
|
||
if (!('roles' in user) || !Array.isArray(user.roles)) { | ||
return true; | ||
} | ||
|
||
return !excludedRoles.some(role => user.roles.includes(role)); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
...ages/TransactionMonitoringAlerts/components/AlertsAssignDropdown/AlertsAssignDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters