Skip to content

Commit

Permalink
chore(app): remove useless selectors (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
rap2hpoutre authored Mar 28, 2022
1 parent 156a2c2 commit bed2abc
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions app/src/recoil/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,64 +301,3 @@ export const territoriesSearchSelector = selectorFamily({
return filterBySearch(search, territories);
},
});

export const territoriesFullSearchSelector = selectorFamily({
key: 'territoriesFullSearchSelector',
get:
({ search = '' }) =>
({ get }) => {
const territories = get(territoriesState);
if (!search.length) return territories;

const territoryObservations = get(onlyFilledObservationsTerritories);

const territoriesIdsByTerritoriesSearch = filterBySearch(search, territories).map((t) => t._id);
const territoriesIdsFilteredByObsSearch = filterBySearch(search, territoryObservations).map((obs) => obs.territory);

const territoriesIdsFilterBySearch = [...new Set([...territoriesIdsByTerritoriesSearch, ...territoriesIdsFilteredByObsSearch])];
return territories.filter((t) => territoriesIdsFilterBySearch.includes(t._id));
},
});

export const passagesNonAnonymousPerDatePerTeamSelector = selectorFamily({
key: 'passagesNonAnonymousPerDatePerTeamSelector',
get:
({ date }) =>
({ get }) => {
const currentTeam = get(currentTeamState);
const comments = get(commentsState);
const persons = get(personsState);
return comments
.filter((c) => c.team === currentTeam._id)
.filter((c) => getIsDayWithinHoursOffsetOfDay(c.createdAt, date, currentTeam?.nightSession ? 12 : 0))
.filter((c) => !!(c.comment || '').includes('Passage enregistré'))
.map((passage) => {
const commentPopulated = { ...passage };
if (passage.person) {
commentPopulated.person = persons.find((p) => p._id === passage?.person);
commentPopulated.type = 'person';
}
return commentPopulated;
});
},
});

export const numberOfPassagesNonAnonymousPerDatePerTeamSelector = selectorFamily({
key: 'numberOfPassagesNonAnonymousPerDatePerTeamSelector',
get:
({ date }) =>
({ get }) => {
const nonAnonymousPassages = get(passagesNonAnonymousPerDatePerTeamSelector({ date }));
return nonAnonymousPassages?.length || 0;
},
});

export const numberOfPassagesAnonymousPerDatePerTeamSelector = selectorFamily({
key: 'numberOfPassagesAnonymousPerDatePerTeamSelector',
get:
({ date }) =>
({ get }) => {
const todaysReports = get(reportPerDateSelector({ date }));
return todaysReports?.passages || 0;
},
});

0 comments on commit bed2abc

Please sign in to comment.