This repository has been archived on 2021-07-29. You can view files and clone it, but cannot push or open issues or pull requests.
find_coach/src/store/modules/coaches/getters.js
2021-07-28 20:51:47 +02:00

22 lines
548 B
JavaScript

export default {
coaches(state) {
return state.coaches;
},
hasCoaches(state) {
return state.coaches && state.coaches.length > 0;
},
isCoach(_, getters, _2, rootGetters) {
const coaches = getters.coaches;
const userId = rootGetters.userId;
return coaches.some(coach => coach.id === userId);
},
shouldUpdate(state) {
const lastFetch = state.lastFetch;
if (!lastFetch) {
return true;
}
const currentTimeStamp = new Date().getTime();
return (currentTimeStamp - lastFetch) / 1000 > 60;
}
};