diff --git a/src/frontend/apps/desk/src/features/teams/teams-panel/__tests__/PanelTeams.test.tsx b/src/frontend/apps/desk/src/features/teams/teams-panel/__tests__/PanelTeams.test.tsx index 68d355c..5b74e05 100644 --- a/src/frontend/apps/desk/src/features/teams/teams-panel/__tests__/PanelTeams.test.tsx +++ b/src/frontend/apps/desk/src/features/teams/teams-panel/__tests__/PanelTeams.test.tsx @@ -3,6 +3,7 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; +import { useAuthStore } from '@/core/auth'; import { AppWrapper } from '@/tests/utils'; import { Panel } from '../components/Panel'; @@ -23,6 +24,19 @@ describe('PanelTeams', () => { }); it('renders with no team to display', async () => { + useAuthStore.setState({ + userData: { + id: '1', + email: 'test@example.com', + name: 'Test User', + abilities: { + teams: { can_view: true, can_create: true }, + mailboxes: { can_view: true }, + contacts: { can_view: true }, + }, + }, + }); + fetchMock.mock(`end:/teams/?ordering=-created_at`, []); render(, { wrapper: AppWrapper }); diff --git a/src/frontend/apps/desk/src/features/teams/teams-panel/components/PanelActions.tsx b/src/frontend/apps/desk/src/features/teams/teams-panel/components/PanelActions.tsx index 4c1cbe5..dea3ad2 100644 --- a/src/frontend/apps/desk/src/features/teams/teams-panel/components/PanelActions.tsx +++ b/src/frontend/apps/desk/src/features/teams/teams-panel/components/PanelActions.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'; import IconAdd from '@/assets/icons/icon-add.svg'; import IconSort from '@/assets/icons/icon-sort.svg'; import { Box, BoxButton, StyledLink } from '@/components'; +import { useAuthStore } from '@/core/auth'; import { useCunninghamTheme } from '@/cunningham'; import { TeamsOrdering } from '@/features/teams/team-management/api'; @@ -13,6 +14,9 @@ export const PanelActions = () => { const { t } = useTranslation(); const { changeOrdering, ordering } = useTeamStore(); const { colorsTokens } = useCunninghamTheme(); + const { userData } = useAuthStore(); + + const can_create = userData?.abilities?.teams.can_create ?? false; const isSortAsc = ordering === TeamsOrdering.BY_CREATED_ON; @@ -43,17 +47,19 @@ export const PanelActions = () => { >