diff --git a/src/components/FunctionalArea/Modal/Modal.component.tsx b/src/components/FunctionalArea/Modal/Modal.component.tsx index 8e2a02b528cf172eebb868fd183008da565dde12..10ee738f82da351681b36bb019c243f5376e6133 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 3afcf1f8cfc442b64f8ced8934545a33337b4d2c..56e1991ab095814ea1a03a1856b76e4ada43c07d 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 f9d88800610efc49275e3cdad86a19a2396a4d97..f2eecb87c1850948c3364ca310c3215e44704001 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 57d852cd19596f39ccb2476e0aae599d4927be4f..33263ed31bc07d01d342fc24c7381091616602d0 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 9387f79cb62e54c63200f673d2f09781e412faed..1d8a39b5d373ed210a37fc0184a0e28ca18369ff 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 90e7c20d501aa6c7cb50642df1eea295c6406816..867b764c5570ec0ab54a9e69771c981b2d0b9fa1 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 e41e2520df7ff6550b80c93d0749a43c73fbcaa2..5ac42d9c81468344c80657d83a79373ae3574f91 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 5aebfe4aab60a8069093b693861d08f2460eee17..91e4b5f49aa4b41d54bdd9bc258be9e03131f183 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, });