⚡️(app-desk) clean build pages
Prob: Next.js transpiles all the files present in the `pages` directory. But we don't want to transpile the providers neither the Layout components. Solution: We export these components to a core folder.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import fetchMock from 'fetch-mock';
|
||||
|
||||
import { fetchAPI } from '@/api';
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
|
||||
describe('fetchAPI', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { login, useAuthStore } from '@/features/auth';
|
||||
import { login, useAuthStore } from '@/core/auth';
|
||||
|
||||
/**
|
||||
* Retrieves the CSRF token from the document's cookies.
|
||||
|
||||
@@ -3,9 +3,10 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { Auth } from '@/features/auth/Auth';
|
||||
import '@/i18n/initI18n';
|
||||
|
||||
import { Auth } from './auth/Auth';
|
||||
|
||||
/**
|
||||
* QueryClient:
|
||||
* - defaultOptions:
|
||||
@@ -21,11 +22,7 @@ const queryClient = new QueryClient({
|
||||
},
|
||||
});
|
||||
|
||||
export default function AppProvider({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
const { theme } = useCunninghamTheme();
|
||||
|
||||
return (
|
||||
@@ -2,11 +2,7 @@ import { Box } from '@/components';
|
||||
import { HEADER_HEIGHT, Header } from '@/features/header';
|
||||
import { Menu } from '@/features/menu';
|
||||
|
||||
export default function MainLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export function MainLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<Box $height="100vh" $css="overflow:hidden;">
|
||||
<Header />
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
import { User, getMe } from '@/features/auth/api';
|
||||
import { User, getMe } from './api';
|
||||
|
||||
export const login = () => {
|
||||
window.location.replace(
|
||||
2
src/frontend/apps/desk/src/core/index.ts
Normal file
2
src/frontend/apps/desk/src/core/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './AppProvider';
|
||||
export * from './MainLayout';
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
import { User } from '@/features/auth';
|
||||
import { User } from '@/core/auth';
|
||||
import { Invitation } from '@/features/members';
|
||||
import { Role, Team } from '@/features/teams';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
import { User } from '@/features/auth';
|
||||
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';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UseQueryOptions, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
|
||||
import { User } from '@/features/auth';
|
||||
import { User } from '@/core/auth';
|
||||
|
||||
export type UsersParams = {
|
||||
query: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from '@/features/auth';
|
||||
import { User } from '@/core/auth';
|
||||
|
||||
export enum OptionType {
|
||||
INVITATION = 'invitation',
|
||||
|
||||
@@ -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 { useAuthStore } from '@/features/auth';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { Role } from '@/features/teams';
|
||||
import { AppWrapper } from '@/tests/utils';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { Role } from '@/features/teams';
|
||||
|
||||
import { Access } from '../types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from '@/features/auth/';
|
||||
import { User } from '@/core/auth';
|
||||
import { Role, Team } from '@/features/teams/';
|
||||
|
||||
export interface Access {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { PropsWithChildren } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { MainLayout } from '@/core';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { Panel } from '@/features/teams';
|
||||
|
||||
import MainLayout from '../MainLayout';
|
||||
|
||||
export default function TeamLayout({ children }: PropsWithChildren) {
|
||||
export function TeamLayout({ children }: PropsWithChildren) {
|
||||
const { colorsTokens } = useCunninghamTheme();
|
||||
|
||||
return (
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './CardCreateTeam';
|
||||
export * from './Panel/Panel';
|
||||
export * from './TeamInfo';
|
||||
export * from './TeamLayout';
|
||||
|
||||
@@ -5,10 +5,9 @@ import styled from 'styled-components';
|
||||
|
||||
import Icon404 from '@/assets/icons/icon-404.svg';
|
||||
import { Box, StyledLink, Text } from '@/components';
|
||||
import { MainLayout } from '@/core';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import MainLayout from './MainLayout';
|
||||
|
||||
const StyledButton = styled(Button)`
|
||||
width: fit-content;
|
||||
padding-left: 2rem;
|
||||
|
||||
@@ -2,9 +2,9 @@ import type { AppProps } from 'next/app';
|
||||
import Head from 'next/head';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { AppProvider } from '@/core/';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import AppProvider from './AppProvider';
|
||||
import './globals.css';
|
||||
|
||||
type AppPropsWithLayout = AppProps & {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { MainLayout } from '@/core';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import MainLayout from '../MainLayout';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
return <Box>Contacts</Box>;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { MainLayout } from '@/core';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import MainLayout from '../MainLayout';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
return <Box>Favorite</Box>;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { MainLayout } from '@/core';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import MainLayout from '../MainLayout';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
return <Box>Groups</Box>;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { ReactElement } from 'react';
|
||||
|
||||
import { TeamLayout } from '@/features/teams/';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import Teams from './teams/';
|
||||
import TeamLayout from './teams/TeamLayout';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
return <Teams />;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { MainLayout } from '@/core/';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import MainLayout from '../MainLayout';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
return <Box>Recent</Box>;
|
||||
};
|
||||
|
||||
@@ -6,11 +6,9 @@ import { ReactElement } from 'react';
|
||||
import { Box } from '@/components';
|
||||
import { TextErrors } from '@/components/TextErrors';
|
||||
import { MemberGrid } from '@/features/members';
|
||||
import { Role, TeamInfo, useTeam } from '@/features/teams/';
|
||||
import { Role, TeamInfo, TeamLayout, useTeam } from '@/features/teams/';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import TeamLayout from './TeamLayout';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
const {
|
||||
query: { id },
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { CardCreateTeam } from '@/features/teams';
|
||||
import { CardCreateTeam, TeamLayout } from '@/features/teams/';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import TeamLayout from './TeamLayout';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
return (
|
||||
<Box className="p-l" $justify="center" $align="start" $height="inherit">
|
||||
|
||||
@@ -4,10 +4,9 @@ import { useTranslation } from 'react-i18next';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Box, StyledLink } from '@/components';
|
||||
import { TeamLayout } from '@/features/teams/';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
import TeamLayout from './TeamLayout';
|
||||
|
||||
const StyledButton = styled(Button)`
|
||||
width: fit-content;
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user