Cleared of the stuff the EnCoach team wanted changed

This commit is contained in:
Tiago Ribeiro
2024-10-28 14:40:26 +00:00
parent 0becd295b0
commit fa0c502467
34 changed files with 166 additions and 107 deletions

View File

@@ -42,6 +42,13 @@ export function findAllowedEntities(user: User, entities: EntityWithRoles[], per
return allowedEntities
}
export function findAllowedEntitiesSomePermissions(user: User, entities: EntityWithRoles[], permissions: RolePermission[]) {
if (["admin", "developer"].includes(user?.type)) return entities
const allowedEntities = entities.filter((e) => permissions.some((p) => doesEntityAllow(user, e, p)))
return allowedEntities
}
export function doesEntityAllow(user: User, entity: EntityWithRoles, permission: RolePermission) {
if (["admin", "developer"].includes(user?.type)) return true

View File

@@ -20,7 +20,7 @@ const getFieldValue = (fields: string[], data: any): string | string[] => {
return data;
};
export const search = (text: string, fields: string[][], rows: any[]) => {
export const search = <T>(text: string, fields: string[][], rows: T[]) => {
const searchText = text.toLowerCase();
return rows.filter((row) => {
return fields.some((fieldsKeys) => {