🚚(frontend) change teams feature architecture

Changes the teams feature architecture, centralizing
all the teams-related features inside a teams folder.
This commit is contained in:
Anthony LC
2024-06-28 12:14:06 +02:00
committed by Anthony LC
parent 4d1aafe0d9
commit a400c12037
61 changed files with 72 additions and 53 deletions

View File

@@ -2,10 +2,9 @@ import { useMutation } from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { User } from '@/core/auth';
import { Invitation } from '@/features/members';
import { Role, Team } from '@/features/teams';
import { Role, Team } from '@/features/teams/team-management';
import { OptionType } from '../types';
import { Invitation, OptionType } from '../types';
interface CreateInvitationParams {
email: User['email'];

View File

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

View File

@@ -2,7 +2,7 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query';
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
import { User } from '@/core/auth';
import { Team } from '@/features/teams';
import { Team } from '@/features/teams/team-management';
export type UsersParams = {
query: string;

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 } from '@/features/members';
import { Role, Team } from '@/features/teams';
import { ChooseRole } from '@/features/teams/member-management';
import { Role, Team } from '@/features/teams/team-management';
import { useCreateInvitation, useCreateTeamAccess } from '../api';
import IconAddMember from '../assets/add-member.svg';

View File

@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Options } from 'react-select';
import AsyncSelect from 'react-select/async';
import { Team } from '@/features/teams';
import { Team } from '@/features/teams/team-management';
import { isValidEmail } from '@/utils';
import { KEY_LIST_USER, useUsers } from '../api/useUsers';

View File

@@ -1,5 +1,7 @@
import { User } from '@/core/auth';
import { Role, Team } from '../team-management';
export enum OptionType {
INVITATION = 'invitation',
NEW_MEMBER = 'new_member',
@@ -24,3 +26,13 @@ export interface OptionNewMember {
}
export type OptionSelect = OptionNewMember | OptionInvitation;
export interface Invitation {
id: string;
created_at: string;
email: string;
team: Team['id'];
role: Role;
issuer: User['id'];
is_expired: boolean;
}

View File

@@ -2,7 +2,7 @@ import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import fetchMock from 'fetch-mock';
import { Role, Team } from '@/features/teams';
import { Role, Team } from '@/features/teams/team-management';
import { AppWrapper } from '@/tests/utils';
import { MemberAction } from '../components/MemberAction';

View File

@@ -3,7 +3,7 @@ import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { Role, Team } from '@/features/teams';
import { Role, Team } from '@/features/teams/team-management';
import { AppWrapper } from '@/tests/utils';
import { MemberGrid } from '../components/MemberGrid';

View File

@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { useAuthStore } from '@/core/auth';
import { Role } from '@/features/teams';
import { Role } from '@/features/teams/team-management';
import { AppWrapper } from '@/tests/utils';
import { ModalRole } from '../components/ModalRole';

View File

@@ -5,7 +5,7 @@ import {
} from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { KEY_LIST_TEAM, KEY_TEAM } from '@/features/teams/';
import { KEY_LIST_TEAM, KEY_TEAM } from '@/features/teams/team-management';
import { KEY_LIST_TEAM_ACCESSES } from './useTeamsAccesses';

View File

@@ -5,7 +5,7 @@ import {
} from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { KEY_TEAM, Role } from '@/features/teams/';
import { KEY_TEAM, Role } from '@/features/teams/team-management';
import { Access } from '../types';

View File

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

View File

@@ -3,7 +3,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Box, DropButton, IconOptions, Text } from '@/components';
import { Role, Team } from '@/features/teams';
import { Role, Team } from '@/features/teams/team-management';
import { Access } from '../types';

View File

@@ -10,10 +10,10 @@ import { useTranslation } from 'react-i18next';
import IconUser from '@/assets/icons/icon-user.svg';
import { Box, Card, TextErrors } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { ModalAddMembers } from '@/features/addMembers';
import { Role, Team } from '@/features/teams';
import { ModalAddMembers } from '@/features/teams/member-add';
import { Role, Team } from '@/features/teams/team-management';
import { useTeamAccesses } from '../api/';
import { useTeamAccesses } from '../api';
import { PAGE_SIZE } from '../conf';
import { MemberAction } from './MemberAction';

View File

@@ -11,7 +11,7 @@ import { useRouter } from 'next/navigation';
import IconUser from '@/assets/icons/icon-user.svg';
import { Box, Text, TextErrors } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { Role, Team } from '@/features/teams/';
import { Role, Team } from '@/features/teams/team-management';
import { useDeleteTeamAccess } from '../api/useDeleteTeamAccess';
import { useWhoAmI } from '../hooks/useWhoAmI';

View File

@@ -9,7 +9,7 @@ import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Box, Text, TextErrors } from '@/components';
import { Role } from '@/features/teams';
import { Role } from '@/features/teams/team-management';
import { useUpdateTeamAccess } from '../api/useUpdateTeamAccess';
import { useWhoAmI } from '../hooks/useWhoAmI';

View File

@@ -1,5 +1,5 @@
import { useAuthStore } from '@/core/auth';
import { Role } from '@/features/teams';
import { Role } from '@/features/teams/team-management';
import { Access } from '../types';

View File

@@ -1,5 +1,5 @@
import { User } from '@/core/auth';
import { Role, Team } from '@/features/teams/';
import { Role } from '@/features/teams/team-management';
export interface Access {
id: string;
@@ -13,13 +13,3 @@ export interface Access {
set_role_to: Role[];
};
}
export interface Invitation {
id: string;
created_at: string;
email: string;
team: Team['id'];
role: Role;
issuer: User['id'];
is_expired: boolean;
}

View File

@@ -3,7 +3,7 @@ import { PropsWithChildren } from 'react';
import { Box } from '@/components';
import { MainLayout } from '@/core';
import { useCunninghamTheme } from '@/cunningham';
import { Panel } from '@/features/teams';
import { Panel } from '@/features/teams/teams-panel';
export function TeamLayout({ children }: PropsWithChildren) {
const { colorsTokens } = useCunninghamTheme();

View File

@@ -1,4 +1,3 @@
export * from './CardCreateTeam';
export * from './Panel/Panel';
export * from './TeamInfo';
export * from './TeamLayout';

View File

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

View File

@@ -1,4 +1,4 @@
import { Access } from '@/features/members';
import { Access } from '@/features/teams/member-management';
export enum Role {
MEMBER = 'member',

View File

@@ -3,10 +3,10 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { Panel } from '@/features/teams';
import { AppWrapper } from '@/tests/utils';
import { TeamList } from '../components/Panel/TeamList';
import { Panel } from '../components/Panel';
import { TeamList } from '../components/TeamList';
window.HTMLElement.prototype.scroll = function () {};

View File

Before

Width:  |  Height:  |  Size: 617 B

After

Width:  |  Height:  |  Size: 617 B

View File

@@ -3,7 +3,8 @@ import { useTranslation } from 'react-i18next';
import { Box, BoxButton, Text } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import IconOpenClose from '@/features/teams/assets/icon-open-close.svg';
import IconOpenClose from '../assets/icon-open-close.svg';
import { PanelActions } from './PanelActions';
import { TeamList } from './TeamList';

View File

@@ -3,10 +3,11 @@ import { useTranslation } from 'react-i18next';
import { Box, BoxButton, StyledLink } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import { TeamsOrdering } from '@/features/teams/api/';
import IconAdd from '@/features/teams/assets/icon-add.svg';
import IconSort from '@/features/teams/assets/icon-sort.svg';
import { useTeamStore } from '@/features/teams/store/useTeamsStore';
import { TeamsOrdering } from '@/features/teams/team-management/api';
import IconAdd from '../assets/icon-add.svg';
import IconSort from '../assets/icon-sort.svg';
import { useTeamStore } from '../store/useTeamsStore';
export const PanelActions = () => {
const { t } = useTranslation();

View File

@@ -5,8 +5,9 @@ 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/';
import IconNone from '@/features/teams/assets/icon-none.svg';
import { Team } from '@/features/teams/team-management';
import IconNone from '../assets/icon-none.svg';
interface TeamProps {
team: Team;

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
import { create } from 'zustand';
import { TeamsOrdering } from '../api/useTeams';
import { TeamsOrdering } from '@/features/teams/team-management/api';
interface TeamsStore {
ordering: TeamsOrdering;

View File

@@ -1,6 +1,6 @@
import type { ReactElement } from 'react';
import { TeamLayout } from '@/features/teams/';
import { TeamLayout } from '@/features/teams/team-management';
import { NextPageWithLayout } from '@/types/next';
import Teams from './teams/';

View File

@@ -5,8 +5,13 @@ import { ReactElement } from 'react';
import { Box } from '@/components';
import { TextErrors } from '@/components/TextErrors';
import { MemberGrid } from '@/features/members';
import { Role, TeamInfo, TeamLayout, useTeam } from '@/features/teams/';
import { MemberGrid } from '@/features/teams/member-management';
import {
Role,
TeamInfo,
TeamLayout,
useTeam,
} from '@/features/teams/team-management';
import { NextPageWithLayout } from '@/types/next';
const Page: NextPageWithLayout = () => {

View File

@@ -1,7 +1,7 @@
import { ReactElement } from 'react';
import { Box } from '@/components';
import { CardCreateTeam, TeamLayout } from '@/features/teams/';
import { CardCreateTeam, TeamLayout } from '@/features/teams/team-management';
import { NextPageWithLayout } from '@/types/next';
const Page: NextPageWithLayout = () => {

View File

@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import styled from 'styled-components';
import { Box, StyledLink } from '@/components';
import { TeamLayout } from '@/features/teams/';
import { TeamLayout } from '@/features/teams/team-management';
import { NextPageWithLayout } from '@/types/next';
const StyledButton = styled(Button)`