diff --git a/CHANGELOG b/CHANGELOG index 347b9405578eb7ea6e5cab9cd125b7da2eced8c2..2f472f0f7fac5b33057733252651962076a211e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +minerva-front (18.0.2) stable; urgency=medium + * Bug fix: Terms of Service modal is not hidden by Select project modal when + login via ORCID (#305) + + -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 30 Oct 2024 13:00:00 +0200 + minerva-front (18.0.1) stable; urgency=medium * Bug fix: show cookie baner only when cookie baner link is provided (#304) * Bug fix: when link to submap is provided add submap name (#303) diff --git a/src/components/FunctionalArea/Modal/ToSModal/ToSModal.component.tsx b/src/components/FunctionalArea/Modal/ToSModal/ToSModal.component.tsx index 7d3d4e766253a5b8f061f9dc0758f65f4e10df2e..789e9fa033716df99f2660e2df9dc8db9e62d59a 100644 --- a/src/components/FunctionalArea/Modal/ToSModal/ToSModal.component.tsx +++ b/src/components/FunctionalArea/Modal/ToSModal/ToSModal.component.tsx @@ -3,7 +3,7 @@ import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { Button } from '@/shared/Button'; import { getSessionValid, logout, updateUser } from '@/redux/user/user.thunks'; -import { closeModal } from '@/redux/modal/modal.slice'; +import { closeModal, openSelectProjectModal } from '@/redux/modal/modal.slice'; import { userSelector } from '@/redux/user/user.selectors'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { termsOfServiceValSelector } from '@/redux/configuration/configuration.selectors'; @@ -15,13 +15,14 @@ export const ToSModal: React.FC = () => { const termsOfService = useAppSelector(termsOfServiceValSelector); const updateUserTosHandler = async (): Promise<void> => { - // eslint-disable-next-line no-console - console.log('update'); if (userData) { const user = { ...userData, termsOfUseConsent: true }; await dispatch(updateUser(user)); await dispatch(getSessionValid()); dispatch(closeModal()); + if (userData.orcidId && userData.orcidId !== '') { + dispatch(openSelectProjectModal()); + } } }; diff --git a/src/redux/modal/modal.reducers.ts b/src/redux/modal/modal.reducers.ts index 236f7f809f2b3d01bca4d20b095ad25917dba6a8..a3704696a08a6a8531a19b5e0d23cecc1ea095ae 100644 --- a/src/redux/modal/modal.reducers.ts +++ b/src/redux/modal/modal.reducers.ts @@ -3,6 +3,13 @@ import { PayloadAction } from '@reduxjs/toolkit'; import { ErrorData } from '@/utils/error-report/ErrorData'; import { ModalState, OpenEditOverlayModalAction } from './modal.types'; +const getOpenedModel = (state: ModalState): ModalName | null => { + if (state.isOpen) { + return state.modalName; + } + return null; +}; + export const openModalReducer = (state: ModalState, action: PayloadAction<ModalName>): void => { state.isOpen = true; state.modalName = action.payload; @@ -74,9 +81,11 @@ export const openAccessDeniedModalReducer = (state: ModalState): void => { }; export const openSelectProjectModalReducer = (state: ModalState): void => { - state.isOpen = true; - state.modalName = 'select-project'; - state.modalTitle = 'Select project!'; + if (getOpenedModel(state) !== 'terms-of-service') { + state.isOpen = true; + state.modalName = 'select-project'; + state.modalTitle = 'Select project!'; + } }; export const setOverviewImageIdReducer = ( diff --git a/src/redux/user/user.thunks.ts b/src/redux/user/user.thunks.ts index 9b016dd81526e58f529f591b18c39c7d9f451bf0..89e404dadd301142b1cbbe4668fb59db73c434d9 100644 --- a/src/redux/user/user.thunks.ts +++ b/src/redux/user/user.thunks.ts @@ -138,7 +138,7 @@ export const updateUser = createAsyncThunk<undefined, User, ThunkConfig>( }, ); - validateDataUsingZodSchema(newUser, userSchema); + validateDataUsingZodSchema(newUser.data, userSchema); showToast({ type: 'success', message: 'ToS agreement registered' }); } catch (error) {