Skip to content
Snippets Groups Projects
Commit fb815716 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

terms of service modal is not hidden by select project

parent 591a2b63
No related branches found
No related tags found
2 merge requests!289Resolve "allow to have plugins without panel",!284Resolve "ToS for orcid users"
Pipeline #97088 passed
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 minerva-front (18.0.1) stable; urgency=medium
* Bug fix: show cookie baner only when cookie baner link is provided (#304) * 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) * Bug fix: when link to submap is provided add submap name (#303)
......
...@@ -3,7 +3,7 @@ import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; ...@@ -3,7 +3,7 @@ import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { Button } from '@/shared/Button'; import { Button } from '@/shared/Button';
import { getSessionValid, logout, updateUser } from '@/redux/user/user.thunks'; 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 { userSelector } from '@/redux/user/user.selectors';
import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { termsOfServiceValSelector } from '@/redux/configuration/configuration.selectors'; import { termsOfServiceValSelector } from '@/redux/configuration/configuration.selectors';
...@@ -15,13 +15,14 @@ export const ToSModal: React.FC = () => { ...@@ -15,13 +15,14 @@ export const ToSModal: React.FC = () => {
const termsOfService = useAppSelector(termsOfServiceValSelector); const termsOfService = useAppSelector(termsOfServiceValSelector);
const updateUserTosHandler = async (): Promise<void> => { const updateUserTosHandler = async (): Promise<void> => {
// eslint-disable-next-line no-console
console.log('update');
if (userData) { if (userData) {
const user = { ...userData, termsOfUseConsent: true }; const user = { ...userData, termsOfUseConsent: true };
await dispatch(updateUser(user)); await dispatch(updateUser(user));
await dispatch(getSessionValid()); await dispatch(getSessionValid());
dispatch(closeModal()); dispatch(closeModal());
if (userData.orcidId && userData.orcidId !== '') {
dispatch(openSelectProjectModal());
}
} }
}; };
......
...@@ -3,6 +3,13 @@ import { PayloadAction } from '@reduxjs/toolkit'; ...@@ -3,6 +3,13 @@ import { PayloadAction } from '@reduxjs/toolkit';
import { ErrorData } from '@/utils/error-report/ErrorData'; import { ErrorData } from '@/utils/error-report/ErrorData';
import { ModalState, OpenEditOverlayModalAction } from './modal.types'; 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 => { export const openModalReducer = (state: ModalState, action: PayloadAction<ModalName>): void => {
state.isOpen = true; state.isOpen = true;
state.modalName = action.payload; state.modalName = action.payload;
...@@ -74,9 +81,11 @@ export const openAccessDeniedModalReducer = (state: ModalState): void => { ...@@ -74,9 +81,11 @@ export const openAccessDeniedModalReducer = (state: ModalState): void => {
}; };
export const openSelectProjectModalReducer = (state: ModalState): void => { export const openSelectProjectModalReducer = (state: ModalState): void => {
state.isOpen = true; if (getOpenedModel(state) !== 'terms-of-service') {
state.modalName = 'select-project'; state.isOpen = true;
state.modalTitle = 'Select project!'; state.modalName = 'select-project';
state.modalTitle = 'Select project!';
}
}; };
export const setOverviewImageIdReducer = ( export const setOverviewImageIdReducer = (
......
...@@ -138,7 +138,7 @@ export const updateUser = createAsyncThunk<undefined, User, ThunkConfig>( ...@@ -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' }); showToast({ type: 'success', message: 'ToS agreement registered' });
} catch (error) { } catch (error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment