feat: rewrite auth (#364)

* feat: wip rewrite auth

* feat: restructure folders and fix stories and tests

* feat: remove auth provider and fix tests
This commit is contained in:
Jérémy M
2023-06-23 17:49:50 +02:00
committed by GitHub
parent 1c7980b270
commit c6708b2c1f
54 changed files with 1268 additions and 584 deletions

View File

@ -1,22 +1,34 @@
import { MemoryRouter } from 'react-router-dom';
import { ApolloProvider } from '@apollo/client';
import { ThemeProvider } from '@emotion/react';
import { RecoilRoot } from 'recoil';
import { RecoilRoot, useRecoilState } from 'recoil';
import { currentUserState } from '@/auth/states/currentUserState';
import { isAuthenticatingState } from '@/auth/states/isAuthenticatingState';
import { darkTheme } from '@/ui/layout/styles/themes';
import { App } from '~/App';
import { AuthProvider } from '~/providers/AuthProvider';
import { FullHeightStorybookLayout } from '~/testing/FullHeightStorybookLayout';
import { mockedUsersData } from '~/testing/mock-data/users';
import { mockedClient } from '~/testing/mockedClient';
export const render = () => renderWithDarkMode(false);
const MockedAuth: React.FC<React.PropsWithChildren> = ({ children }) => {
const [, setCurrentUser] = useRecoilState(currentUserState);
const [, setIsAuthenticating] = useRecoilState(isAuthenticatingState);
setCurrentUser(mockedUsersData[0]);
setIsAuthenticating(false);
return <>{children}</>;
};
export const renderWithDarkMode = (forceDarkMode?: boolean) => {
const AppInStoryBook = (
<FullHeightStorybookLayout>
<AuthProvider>
<MockedAuth>
<App />
</AuthProvider>
</MockedAuth>
</FullHeightStorybookLayout>
);