🚚(frontend) move auth to its own feature
We will move auth to its own feature to make it easier to manage and to make it more modular.
This commit is contained in:
@@ -3,10 +3,10 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { Auth } from '@/features/auth';
|
||||
import '@/i18n/initI18n';
|
||||
import { useResponsiveStore } from '@/stores/';
|
||||
|
||||
import { Auth } from './auth/';
|
||||
import { ConfigProvider } from './config/';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export * from './api/types';
|
||||
export * from './Auth';
|
||||
export * from './ButtonLogin';
|
||||
export * from './useAuthStore';
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './AppProvider';
|
||||
export * from './auth';
|
||||
export * from './config';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PropsWithChildren, useEffect, useState } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
|
||||
import { useAuthStore } from './useAuthStore';
|
||||
import { useAuthStore } from '../stores/useAuthStore';
|
||||
|
||||
/**
|
||||
* TODO: Remove this restriction when we will have a homepage design for non-authenticated users.
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Button } from '@openfun/cunningham-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
|
||||
export const ButtonLogin = () => {
|
||||
const { t } = useTranslation();
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './Auth';
|
||||
export * from './ButtonLogin';
|
||||
3
src/frontend/apps/impress/src/features/auth/index.ts
Normal file
3
src/frontend/apps/impress/src/features/auth/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './api/types';
|
||||
export * from './components';
|
||||
export * from './stores';
|
||||
@@ -0,0 +1 @@
|
||||
export * from './useAuthStore';
|
||||
@@ -3,8 +3,8 @@ import { create } from 'zustand';
|
||||
import { baseApiUrl } from '@/api';
|
||||
import { terminateCrispSession } from '@/services';
|
||||
|
||||
import { User, getMe } from './api';
|
||||
import { PATH_AUTH_LOCAL_STORAGE } from './conf';
|
||||
import { User, getMe } from '../api';
|
||||
import { PATH_AUTH_LOCAL_STORAGE } from '../conf';
|
||||
|
||||
interface AuthStore {
|
||||
initiated: boolean;
|
||||
@@ -10,7 +10,7 @@ import { css } from 'styled-components';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import { Box, TextErrors } from '@/components';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
import { Doc } from '@/features/docs/doc-management';
|
||||
|
||||
import { useUploadFile } from '../hook';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from '@/core';
|
||||
import { User } from '@/features/auth';
|
||||
|
||||
export interface Access {
|
||||
id: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
import { User } from '@/core/auth';
|
||||
import { User } from '@/features/auth';
|
||||
import {
|
||||
Access,
|
||||
Doc,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
import { User } from '@/core/auth';
|
||||
import { User } from '@/features/auth';
|
||||
import { Doc, Role } from '@/features/docs/doc-management';
|
||||
import { Invitation, OptionType } from '@/features/docs/doc-share/types';
|
||||
import { ContentLanguage } from '@/i18n/types';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UseQueryOptions, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
|
||||
import { User } from '@/core/auth';
|
||||
import { User } from '@/features/auth';
|
||||
import { Doc } from '@/features/docs/doc-management';
|
||||
|
||||
export type UsersParams = {
|
||||
|
||||
@@ -9,8 +9,8 @@ import { css } from 'styled-components';
|
||||
|
||||
import { APIError } from '@/api';
|
||||
import { Box } from '@/components';
|
||||
import { User } from '@/core';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { User } from '@/features/auth';
|
||||
import { Doc, Role } from '@/features/docs';
|
||||
import { useLanguage } from '@/i18n/hooks/useLanguage';
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import { Button } from '@openfun/cunningham-react';
|
||||
import { css } from 'styled-components';
|
||||
|
||||
import { Box, Icon, Text } from '@/components';
|
||||
import { User } from '@/core';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { User } from '@/features/auth';
|
||||
|
||||
type Props = {
|
||||
user: User;
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
DropdownMenuOption,
|
||||
IconOptions,
|
||||
} from '@/components';
|
||||
import { User } from '@/core';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { User } from '@/features/auth';
|
||||
import { Doc, Role } from '@/features/docs/doc-management';
|
||||
|
||||
import { useDeleteDocInvitation, useUpdateDocInvitation } from '../api';
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
QuickSearchData,
|
||||
QuickSearchGroup,
|
||||
} from '@/components/quick-search/';
|
||||
import { User } from '@/core';
|
||||
import { User } from '@/features/auth';
|
||||
import { Access, Doc } from '@/features/docs';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
import { isValidEmail } from '@/utils';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { css } from 'styled-components';
|
||||
|
||||
import { Box, Icon, Text } from '@/components';
|
||||
import { User } from '@/core';
|
||||
import { User } from '@/features/auth';
|
||||
|
||||
import { SearchUserRow } from './SearchUserRow';
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
QuickSearchItemContent,
|
||||
QuickSearchItemContentProps,
|
||||
} from '@/components/quick-search';
|
||||
import { User } from '@/core';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { User } from '@/features/auth';
|
||||
|
||||
import { UserAvatar } from './UserAvatar';
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { css } from 'styled-components';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { User } from '@/core';
|
||||
import { tokens } from '@/cunningham';
|
||||
import { User } from '@/features/auth';
|
||||
|
||||
const colors = tokens.themes.default.theme.colors;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
import { Access, Role } from '@/features/docs/doc-management';
|
||||
|
||||
export const useWhoAmI = (access: Access) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from '@/core/auth';
|
||||
import { User } from '@/features/auth';
|
||||
import { Role } from '@/features/docs';
|
||||
|
||||
export interface Invitation {
|
||||
|
||||
@@ -4,8 +4,8 @@ import { useTranslation } from 'react-i18next';
|
||||
import { css } from 'styled-components';
|
||||
|
||||
import { Box, Icon, StyledLink } from '@/components/';
|
||||
import { ButtonLogin } from '@/core/auth';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { ButtonLogin } from '@/features/auth';
|
||||
import { LanguagePicker } from '@/features/language';
|
||||
import { useLeftPanelStore } from '@/features/left-panel';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
@@ -3,8 +3,8 @@ import { useCallback, useEffect } from 'react';
|
||||
import { createGlobalStyle, css } from 'styled-components';
|
||||
|
||||
import { Box, SeparatedSection } from '@/components';
|
||||
import { ButtonLogin } from '@/core';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { ButtonLogin } from '@/features/auth';
|
||||
import { HEADER_HEIGHT } from '@/features/header/conf';
|
||||
import { LanguagePicker } from '@/features/language';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation';
|
||||
import { PropsWithChildren } from 'react';
|
||||
|
||||
import { Box, Icon, SeparatedSection } from '@/components';
|
||||
import { useAuthStore } from '@/core';
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
import { useCreateDoc } from '@/features/docs/doc-management';
|
||||
import { DocSearchModal } from '@/features/docs/doc-search';
|
||||
import { useCmdK } from '@/hook/useCmdK';
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useRouter } from 'next/router';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { Box, Text, TextErrors } from '@/components';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { useAuthStore } from '@/features/auth';
|
||||
import { DocEditor } from '@/features/docs/doc-editor';
|
||||
import {
|
||||
Doc,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { Crisp } from 'crisp-sdk-web';
|
||||
|
||||
import { User } from '@/core';
|
||||
import { User } from '@/features/auth';
|
||||
|
||||
export const initializeCrispSession = (user: User) => {
|
||||
if (!Crisp.isCrispInjected()) {
|
||||
|
||||
Reference in New Issue
Block a user