🏷️(app-desk) move Role type to Team

We need the Role type in Team as well.
Better to move it to the highest level.
This commit is contained in:
Anthony LC
2024-03-25 15:57:05 +01:00
committed by Anthony LC
parent 25af872a2a
commit f591c95a92
23 changed files with 41 additions and 35 deletions

View File

@@ -2,8 +2,8 @@ import { useMutation } from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { User } from '@/features/auth';
import { Invitation, Role } from '@/features/members';
import { Team } from '@/features/teams';
import { Invitation } from '@/features/members';
import { Role, Team } from '@/features/teams';
import { OptionType } from '../types';

View File

@@ -2,8 +2,8 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { User } from '@/features/auth';
import { Access, KEY_LIST_TEAM_ACCESSES, Role } from '@/features/members';
import { KEY_LIST_TEAM, KEY_TEAM, Team } from '@/features/teams';
import { Access, KEY_LIST_TEAM_ACCESSES } from '@/features/members';
import { KEY_LIST_TEAM, KEY_TEAM, Role, Team } from '@/features/teams';
import { OptionType } from '../types';

View File

@@ -12,8 +12,8 @@ import { createGlobalStyle } from 'styled-components';
import { APIError } from '@/api';
import { Box, Text } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { ChooseRole, Role } from '@/features/members';
import { Team } from '@/features/teams';
import { ChooseRole } from '@/features/members';
import { Role, Team } from '@/features/teams';
import { useCreateInvitation, useCreateTeamAccess } from '../api';
import IconAddMember from '../assets/add-member.svg';

View File

@@ -2,10 +2,11 @@ import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import fetchMock from 'fetch-mock';
import { Role } from '@/features/teams';
import { AppWrapper } from '@/tests/utils';
import { MemberAction } from '../components/MemberAction';
import { Access, Role } from '../types';
import { Access } from '../types';
const access: Access = {
id: '789',

View File

@@ -3,11 +3,11 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { Team } from '@/features/teams/api';
import { Role, Team } from '@/features/teams';
import { AppWrapper } from '@/tests/utils';
import { MemberGrid } from '../components/MemberGrid';
import { Access, Role } from '../types';
import { Access } from '../types';
const team = {
id: '123456',

View File

@@ -4,10 +4,11 @@ import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { useAuthStore } from '@/features/auth';
import { Role } from '@/features/teams';
import { AppWrapper } from '@/tests/utils';
import { ModalRole } from '../components/ModalRole';
import { Access, Role } from '../types';
import { Access } from '../types';
const toast = jest.fn();
jest.mock('@openfun/cunningham-react', () => ({

View File

@@ -5,9 +5,9 @@ import {
} from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { KEY_TEAM } from '@/features/teams/api/useTeam';
import { KEY_TEAM, Role } from '@/features/teams/';
import { Access, Role } from '../types';
import { Access } from '../types';
import { KEY_LIST_TEAM_ACCESSES } from './useTeamsAccesses';

View File

@@ -1,7 +1,7 @@
import { Radio, RadioGroup } from '@openfun/cunningham-react';
import { useTranslation } from 'react-i18next';
import { Role } from '..';
import { Role } from '@/features/teams';
interface ChooseRoleProps {
currentRole: Role;

View File

@@ -3,8 +3,9 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { DropButton, IconOptions, Text } from '@/components';
import { Role } from '@/features/teams';
import { Access, Role } from '../types';
import { Access } from '../types';
import { ModalRole } from './ModalRole';

View File

@@ -6,11 +6,10 @@ import IconUser from '@/assets/icons/icon-user.svg';
import { Box, Card, TextErrors } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { ModalAddMembers } from '@/features/addMembers';
import { Team } from '@/features/teams';
import { Role, Team } from '@/features/teams';
import { useTeamAccesses } from '../api/';
import { PAGE_SIZE } from '../conf';
import { Role } from '../types';
import { MemberAction } from './MemberAction';

View File

@@ -10,9 +10,10 @@ import { useTranslation } from 'react-i18next';
import { Box, Text, TextErrors } from '@/components';
import { useAuthStore } from '@/features/auth';
import { Role } from '@/features/teams';
import { useUpdateTeamAccess } from '../api/useUpdateTeamAccess';
import { Access, Role } from '../types';
import { Access } from '../types';
import { ChooseRole } from './ChooseRole';

View File

@@ -1,11 +1,5 @@
import { User } from '@/features/auth/';
import { Team } from '@/features/teams/';
export enum Role {
MEMBER = 'member',
ADMIN = 'administrator',
OWNER = 'owner',
}
import { Role, Team } from '@/features/teams/';
export interface Access {
id: string;

View File

@@ -1,4 +1,3 @@
export * from './types';
export * from './useCreateTeam';
export * from './useTeam';
export * from './useTeams';

View File

@@ -2,7 +2,7 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { Team } from './types';
import { Team } from '../types';
export type TeamParams = {
id: string;

View File

@@ -7,7 +7,7 @@ import {
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
import { Team } from './types';
import { Team } from '../types';
export enum TeamsOrdering {
BY_CREATED_ON = 'created_at',

View File

@@ -2,7 +2,8 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { Team } from './types';
import { Team } from '../types';
import { KEY_TEAM } from './useTeam';
import { KEY_LIST_TEAM } from './useTeams';

View File

@@ -11,8 +11,9 @@ import { useState } from 'react';
import { Box, Text } from '@/components';
import useCunninghamTheme from '@/cunningham/useCunninghamTheme';
import { Team, useUpdateTeam } from '../api';
import { useUpdateTeam } from '../api';
import IconEdit from '../assets/icon-edit.svg';
import { Team } from '../types';
import { InputTeamName } from './InputTeamName';

View File

@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
import IconGroup from '@/assets/icons/icon-group.svg';
import { Box, StyledLink, Text } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { Team } from '@/features/teams/api/';
import { Team } from '@/features/teams/';
import IconNone from '@/features/teams/assets/icon-none.svg';
interface TeamProps {

View File

@@ -4,8 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Box, Text } from '@/components';
import { InfiniteScroll } from '@/components/InfiniteScroll';
import { Team, useTeams } from '@/features/teams/api/';
import { useTeamStore } from '@/features/teams/store/useTeamsStore';
import { Team, useTeamStore, useTeams } from '@/features/teams/';
import { TeamItem } from './TeamItem';

View File

@@ -1,2 +1,4 @@
export * from './components';
export * from './api';
export * from './components';
export * from './types';
export * from './store';

View File

@@ -0,0 +1 @@
export * from './useTeamsStore';

View File

@@ -1,5 +1,11 @@
import { Access } from '@/features/members';
export enum Role {
MEMBER = 'member',
ADMIN = 'administrator',
OWNER = 'owner',
}
export interface Team {
id: string;
name: string;

View File

@@ -5,8 +5,8 @@ import { ReactElement } from 'react';
import { Box } from '@/components';
import { TextErrors } from '@/components/TextErrors';
import { MemberGrid, Role } from '@/features/members';
import { TeamInfo, useTeam } from '@/features/teams/';
import { MemberGrid } from '@/features/members';
import { Role, TeamInfo, useTeam } from '@/features/teams/';
import { NextPageWithLayout } from '@/types/next';
import TeamLayout from './TeamLayout';