Skip to content

Commit

Permalink
refactor: expand canUserEdit function to include all user roles (#3881)
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 authored Oct 30, 2024
1 parent cabf052 commit 736e0fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export const userStore: StateCreator<
const user = get().getUser();
if (!user) return false;

const hasTeamEditorRole = (team: UserTeams) =>
team.role === "teamEditor" && team.team.slug === teamSlug;
const canEditTeam = (team: UserTeams) =>
team.role !== "teamViewer" && team.team.slug === teamSlug;

return user.isPlatformAdmin || user.teams.some(hasTeamEditorRole);
return user.isPlatformAdmin || user.teams.some(canEditTeam);
},

async initUserStore() {
Expand Down

0 comments on commit 736e0fd

Please sign in to comment.