Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(app): remove useless selectors #540

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
},
});