From 0f158a64c62b094080c1ddd4d8aef112b8f333ca Mon Sep 17 00:00:00 2001 From: Piotr Gawron <p.gawron@atcomp.pl> Date: Wed, 4 Sep 2024 13:42:10 +0200 Subject: [PATCH] after signing in with orcid id list of projects is presented --- src/components/FunctionalArea/Modal/Modal.component.tsx | 5 +++++ .../Modal/ModalLayout/ModalLayout.component.tsx | 1 + src/redux/modal/modal.reducers.ts | 6 ++++++ src/redux/modal/modal.slice.ts | 3 +++ src/redux/root/init.thunks.ts | 6 ++++++ src/types/modal.ts | 1 + src/types/query.ts | 2 ++ src/utils/parseQueryToTypes.ts | 1 + 8 files changed, 25 insertions(+) diff --git a/src/components/FunctionalArea/Modal/Modal.component.tsx b/src/components/FunctionalArea/Modal/Modal.component.tsx index 8e2a02b5..10ee738f 100644 --- a/src/components/FunctionalArea/Modal/Modal.component.tsx +++ b/src/components/FunctionalArea/Modal/Modal.component.tsx @@ -57,6 +57,11 @@ export const Modal = (): React.ReactNode => { <AccessDeniedModal /> </ModalLayout> )} + {isOpen && modalName === 'select-project' && ( + <ModalLayout> + <AccessDeniedModal /> + </ModalLayout> + )} {isOpen && modalName === 'add-comment' && ( <ModalLayout> <AddCommentModal /> diff --git a/src/components/FunctionalArea/Modal/ModalLayout/ModalLayout.component.tsx b/src/components/FunctionalArea/Modal/ModalLayout/ModalLayout.component.tsx index 3afcf1f8..56e1991a 100644 --- a/src/components/FunctionalArea/Modal/ModalLayout/ModalLayout.component.tsx +++ b/src/components/FunctionalArea/Modal/ModalLayout/ModalLayout.component.tsx @@ -29,6 +29,7 @@ export const ModalLayout = ({ children }: ModalLayoutProps): JSX.Element => { 'flex h-5/6 w-10/12 flex-col overflow-hidden rounded-lg', modalName === 'login' && 'h-auto w-[400px]', modalName === 'access-denied' && 'h-auto w-[400px]', + modalName === 'select-project' && 'h-auto w-[400px]', modalName === 'add-comment' && 'h-auto w-[400px]', modalName === 'error-report' && 'h-auto w-[800px]', ['edit-overlay', 'logged-in-menu'].includes(modalName) && 'h-auto w-[432px]', diff --git a/src/redux/modal/modal.reducers.ts b/src/redux/modal/modal.reducers.ts index f9d88800..f2eecb87 100644 --- a/src/redux/modal/modal.reducers.ts +++ b/src/redux/modal/modal.reducers.ts @@ -73,6 +73,12 @@ export const openAccessDeniedModalReducer = (state: ModalState): void => { state.modalTitle = 'Access denied!'; }; +export const openSelectProjectModalReducer = (state: ModalState): void => { + state.isOpen = true; + state.modalName = 'select-project'; + state.modalTitle = 'Select project!'; +}; + export const setOverviewImageIdReducer = ( state: ModalState, action: PayloadAction<number>, diff --git a/src/redux/modal/modal.slice.ts b/src/redux/modal/modal.slice.ts index 57d852cd..33263ed3 100644 --- a/src/redux/modal/modal.slice.ts +++ b/src/redux/modal/modal.slice.ts @@ -13,6 +13,7 @@ import { openAddCommentModalReducer, openErrorReportModalReducer, openAccessDeniedModalReducer, + openSelectProjectModalReducer, } from './modal.reducers'; const modalSlice = createSlice({ @@ -31,6 +32,7 @@ const modalSlice = createSlice({ openLoggedInMenuModal: openLoggedInMenuModalReducer, openErrorReportModal: openErrorReportModalReducer, openAccessDeniedModal: openAccessDeniedModalReducer, + openSelectProjectModal: openSelectProjectModalReducer, }, }); @@ -47,6 +49,7 @@ export const { openLoggedInMenuModal, openErrorReportModal, openAccessDeniedModal, + openSelectProjectModal, } = modalSlice.actions; export default modalSlice.reducer; diff --git a/src/redux/root/init.thunks.ts b/src/redux/root/init.thunks.ts index 9387f79c..1d8a39b5 100644 --- a/src/redux/root/init.thunks.ts +++ b/src/redux/root/init.thunks.ts @@ -12,6 +12,8 @@ import { getDrugAutocomplete, getSearchAutocomplete, } from '@/redux/autocomplete/autocomplete.thunks'; +import { openSelectProjectModal } from '@/redux/modal/modal.slice'; +import { getProjects } from '@/redux/projects/projects.thunks'; import { getAllBackgroundsByProjectId } from '../backgrounds/backgrounds.thunks'; import { getConfiguration, getConfigurationOptions } from '../configuration/configuration.thunks'; import { @@ -117,4 +119,8 @@ export const fetchInitialAppData = createAsyncThunk< dispatch(openOverlaysDrawer()); } } + if (queryData.oauthLogin === 'success') { + await dispatch(getProjects()); + dispatch(openSelectProjectModal()); + } }); diff --git a/src/types/modal.ts b/src/types/modal.ts index 90e7c20d..867b764c 100644 --- a/src/types/modal.ts +++ b/src/types/modal.ts @@ -8,4 +8,5 @@ export type ModalName = | 'edit-overlay' | 'error-report' | 'access-denied' + | 'select-project' | 'logged-in-menu'; diff --git a/src/types/query.ts b/src/types/query.ts index e41e2520..5ac42d9c 100644 --- a/src/types/query.ts +++ b/src/types/query.ts @@ -9,6 +9,7 @@ export interface QueryData { initialPosition?: Partial<Point>; overlaysId?: number[]; pluginsId?: string[]; + oauthLogin?: string; } export interface QueryDataParams { @@ -35,4 +36,5 @@ export interface QueryDataRouterParams { z?: string; overlaysId?: string; pluginsId?: string; + oauthLogin?: string; } diff --git a/src/utils/parseQueryToTypes.ts b/src/utils/parseQueryToTypes.ts index 5aebfe4a..91e4b5f4 100644 --- a/src/utils/parseQueryToTypes.ts +++ b/src/utils/parseQueryToTypes.ts @@ -13,4 +13,5 @@ export const parseQueryToTypes = (query: QueryDataRouterParams): QueryData => ({ }, overlaysId: query.overlaysId?.split(',').map(Number), pluginsId: query.pluginsId?.split(',').map(String), + oauthLogin: query.oauthLogin, }); -- GitLab