this.plans.delete(plan.id); } // MARK: Private methods // MARK: Public methods static withFilter(block, plans = this.getState().plans) { return new Map([...plans].filter((entry) => block(entry[1]))); } static withId(id) { return this.getState().plans.get(id); } static withType(type) { return this.withFilter(plan => plan.type == type); } static forUsers() { return this.withType("user"); } static forTeam() { return this.withType("team"); } } export default alt.createStore(PlansStore, 'PlansStore');
// MARK: Private methods // MARK: Public methods static withFilter(block, team_members = this.getState().team_members) { return new Map([...team_members].filter((entry) => block(entry[1]))); } static withId(id) { return this.getState().team_members.get(id); } static forUserWithId(id) { return this.withFilter(team_member => team_member.user_id == id); } static forTeamWithId(id) { return this.withFilter(team_member => team_member.team_id == id); } static forUserWithIdforTeamWithId(user_id, team_id) { const team_members = this.withFilter(team_member => { return team_member.user_id == user_id && team_member.team_id == team_id }); return team_members.values().next().value; } } export default alt.createStore(TeamMembersStore, "TeamMembersStore");
this.setJWT(jwt); this.setUser(user); } setJWT(jwt) { localStorage.setItem("jwt", jwt); this.jwt = jwt; } setUser(user) { this.user = user; } clearAllStores() { localStorage.clear(); alt.recycle(); } // MARK: Private methods // MARK: Public methods static isLoggedIn() { const { jwt, user } = this.getState(); return !!jwt && !!user; } } export default alt.createStore(UserStore, 'UserStore');