MSP-3105 add roleUtils in utils

This commit is contained in:
Anastasiia committed 2024-04-19 14:32:41 +03:00
1 parent 58075955dc
commit 76f2e6d3c3
1 file changed
+16
+16
View File
@@ -0,0 +1,16 @@
import { RoleType } from '@type/roles.type.ts'
export const findExclusiveRole = (
roles: RoleType[],
watchRoles: number[] = []
) => {
let firstExclusiveElement = null
for (let i = 0; i < roles.length; i++) {
const item = roles[i]
if (item.exclusive === true && watchRoles.includes(item.id)) {
firstExclusiveElement = item
break
}
}
return firstExclusiveElement
}