2020-04-30 13:02:56 +02:00
|
|
|
export function selectBoardByUserProjects(boardsByID: any, projectsByName: any) {
|
2019-12-05 13:57:00 +01:00
|
|
|
const userProjects = Object.keys(projectsByName);
|
2020-04-30 13:02:56 +02:00
|
|
|
return Object.keys(boardsByID).reduce((filteredBoardsByID: any, boardID: string) => {
|
2019-12-05 13:57:00 +01:00
|
|
|
const board = boardsByID[boardID];
|
2020-04-30 13:02:56 +02:00
|
|
|
const hasProject = board.projects.length === 0 || board.projects.some((p: any) => userProjects.indexOf(p) !== -1);
|
2019-12-05 13:57:00 +01:00
|
|
|
if (hasProject) {
|
|
|
|
filteredBoardsByID[boardID] = board;
|
|
|
|
}
|
|
|
|
return filteredBoardsByID;
|
|
|
|
}, {});
|
|
|
|
}
|