diff --git a/src/frontend/apps/desk/src/features/teams/api/types.tsx b/src/frontend/apps/desk/src/features/teams/api/types.tsx index b407a86..9274f36 100644 --- a/src/frontend/apps/desk/src/features/teams/api/types.tsx +++ b/src/frontend/apps/desk/src/features/teams/api/types.tsx @@ -10,7 +10,7 @@ export interface Access { user: string; } -export interface TeamResponse { +export interface Team { id: string; name: string; accesses: Access[]; diff --git a/src/frontend/apps/desk/src/features/teams/api/useTeam.tsx b/src/frontend/apps/desk/src/features/teams/api/useTeam.tsx index deb09ca..bff61d2 100644 --- a/src/frontend/apps/desk/src/features/teams/api/useTeam.tsx +++ b/src/frontend/apps/desk/src/features/teams/api/useTeam.tsx @@ -2,29 +2,29 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query'; import { APIError, errorCauses, fetchAPI } from '@/api'; -import { TeamResponse } from './types'; +import { Team } from './types'; export type TeamParams = { id: string; }; -export const getTeam = async ({ id }: TeamParams): Promise => { +export const getTeam = async ({ id }: TeamParams): Promise => { const response = await fetchAPI(`teams/${id}`); if (!response.ok) { throw new APIError('Failed to get the team', await errorCauses(response)); } - return response.json() as Promise; + return response.json() as Promise; }; export const KEY_TEAM = 'team'; export function useTeam( param: TeamParams, - queryConfig?: UseQueryOptions, + queryConfig?: UseQueryOptions, ) { - return useQuery({ + return useQuery({ queryKey: [KEY_TEAM, param], queryFn: () => getTeam(param), ...queryConfig, diff --git a/src/frontend/apps/desk/src/features/teams/api/useTeams.tsx b/src/frontend/apps/desk/src/features/teams/api/useTeams.tsx index 05d1fc7..973a4f3 100644 --- a/src/frontend/apps/desk/src/features/teams/api/useTeams.tsx +++ b/src/frontend/apps/desk/src/features/teams/api/useTeams.tsx @@ -7,7 +7,7 @@ import { import { APIError, APIList, errorCauses, fetchAPI } from '@/api'; -import { TeamResponse } from './types'; +import { Team } from './types'; export enum TeamsOrdering { BY_CREATED_ON = 'created_at', @@ -21,7 +21,7 @@ type TeamsAPIParams = TeamsParams & { page: number; }; -type TeamsResponse = APIList; +type TeamsResponse = APIList; export const getTeams = async ({ ordering, @@ -33,6 +33,7 @@ export const getTeams = async ({ if (!response.ok) { throw new APIError('Failed to get the teams', await errorCauses(response)); } + return response.json() as Promise; }; diff --git a/src/frontend/apps/desk/src/features/teams/components/PanelTeam.tsx b/src/frontend/apps/desk/src/features/teams/components/PanelTeam.tsx index 8f12bf9..da6d1c9 100644 --- a/src/frontend/apps/desk/src/features/teams/components/PanelTeam.tsx +++ b/src/frontend/apps/desk/src/features/teams/components/PanelTeam.tsx @@ -6,11 +6,11 @@ import IconGroup from '@/assets/icons/icon-group.svg'; import { Box, StyledLink, Text } from '@/components'; import { useCunninghamTheme } from '@/cunningham'; -import { TeamResponse } from '../api/types'; +import { Team } from '../api/types'; import IconNone from '../assets/icon-none.svg'; interface TeamProps { - team: TeamResponse; + team: Team; } export const PanelTeam = ({ team }: TeamProps) => { diff --git a/src/frontend/apps/desk/src/features/teams/components/PanelTeams.tsx b/src/frontend/apps/desk/src/features/teams/components/PanelTeams.tsx index 2f03c02..cd48bf9 100644 --- a/src/frontend/apps/desk/src/features/teams/components/PanelTeams.tsx +++ b/src/frontend/apps/desk/src/features/teams/components/PanelTeams.tsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'; import { Box, Text } from '@/components'; import { InfiniteScroll } from '@/components/InfiniteScroll'; -import { TeamResponse } from '../api/types'; +import { Team } from '../api/types'; import { useTeams } from '../api/useTeams'; import { useTeamStore } from '../store/useTeamsStore'; @@ -14,7 +14,7 @@ import { PanelTeam } from './PanelTeam'; interface PanelTeamsStateProps { isLoading: boolean; isError: boolean; - teams?: TeamResponse[]; + teams?: Team[]; } const PanelTeamsState = ({ @@ -76,7 +76,7 @@ export const PanelTeams = () => { const teams = useMemo(() => { return data?.pages.reduce((acc, page) => { return acc.concat(page.results); - }, [] as TeamResponse[]); + }, [] as Team[]); }, [data?.pages]); return ( diff --git a/src/frontend/apps/desk/src/features/teams/components/TeamInfo.tsx b/src/frontend/apps/desk/src/features/teams/components/TeamInfo.tsx index 20d49af..5407ca6 100644 --- a/src/frontend/apps/desk/src/features/teams/components/TeamInfo.tsx +++ b/src/frontend/apps/desk/src/features/teams/components/TeamInfo.tsx @@ -5,10 +5,10 @@ import IconGroup from '@/assets/icons/icon-group2.svg'; import { Box, Card, Text } from '@/components'; import { useCunninghamTheme } from '@/cunningham'; -import { TeamResponse } from '../api/types'; +import { Team } from '../api/types'; interface TeamInfoProps { - team: TeamResponse; + team: Team; } export const TeamInfo = ({ team }: TeamInfoProps) => {