🐛(frontend) fix create team button

The button to create a new team was not displayed properly anymore.
This commit is contained in:
Quentin BEY
2025-05-06 16:17:40 +02:00
parent aa3d90b686
commit f0c609ef0b
5 changed files with 22 additions and 18 deletions

View File

@@ -18,6 +18,11 @@ jest.mock('next/router', () => ({
}),
}));
jest.mock('next/navigation', () => ({
...jest.requireActual('next/navigation'),
useRouter: () => jest.fn(),
}));
describe('PanelTeams', () => {
afterEach(() => {
fetchMock.restore();

View File

@@ -1,9 +1,10 @@
import { useRouter as useNavigate } from 'next/navigation';
import React from 'react';
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 { Box, BoxButton } from '@/components';
import { useAuthStore } from '@/core/auth';
import { useCunninghamTheme } from '@/cunningham';
import { TeamsOrdering } from '@/features/teams/team-management/api';
@@ -15,6 +16,7 @@ export const PanelActions = () => {
const { changeOrdering, ordering } = useTeamStore();
const { colorsTokens } = useCunninghamTheme();
const { userData } = useAuthStore();
const navigate = useNavigate();
const can_create = userData?.abilities?.teams.can_create ?? false;
@@ -48,17 +50,14 @@ export const PanelActions = () => {
<IconSort width={30} height={30} aria-hidden="true" />
</BoxButton>
{can_create && (
<StyledLink href="/teams/create">
<BoxButton
as="span"
$margin={{ all: 'auto' }}
aria-label={t('Add a team')}
$color={colorsTokens()['primary-600']}
tabIndex={-1}
>
<IconAdd width={27} height={27} aria-hidden="true" />
</BoxButton>
</StyledLink>
<BoxButton
$margin={{ all: 'auto' }}
aria-label={t('Add a team')}
$color={colorsTokens()['primary-600']}
onClick={() => void navigate.push('/teams/create')}
>
<IconAdd width={27} height={27} aria-hidden="true" />
</BoxButton>
)}
</Box>
);