diff --git a/src/components/PublicLayout/Header/index.tsx b/src/components/PublicLayout/Header/index.tsx index de192fc9..92653150 100644 --- a/src/components/PublicLayout/Header/index.tsx +++ b/src/components/PublicLayout/Header/index.tsx @@ -37,7 +37,7 @@ const Header = () => { const { keycloak } = useKeycloak(); const query = useQueryParams(); const navigate = useNavigate(); - + const [redirectUri, setRedirectUri] = useState(); const [openLoginModal, setOpenLoginModal] = useState(false); const closeLoginModal = () => setOpenLoginModal(false); @@ -73,6 +73,7 @@ const Header = () => { key="dashboard" icon={} onClick={() => { + setRedirectUri(STATIC_ROUTES.DASHBOARD); trackPublicStudies('Dashboard'); setOpenLoginModal(true); }} @@ -88,6 +89,7 @@ const Header = () => { key="explore-data" icon={} onClick={() => { + setRedirectUri(STATIC_ROUTES.DATA_EXPLORATION); trackPublicStudies('Data Exploration'); setOpenLoginModal(true); }} @@ -99,6 +101,7 @@ const Header = () => { key="variant-data" icon={} onClick={() => { + setRedirectUri(STATIC_ROUTES.VARIANTS); trackPublicStudies('Variants'); setOpenLoginModal(true); }} @@ -110,6 +113,7 @@ const Header = () => { key="analytics-data" icon={} onClick={() => { + setRedirectUri(STATIC_ROUTES.ANALYTICS); trackPublicStudies('Analysis'); setOpenLoginModal(true); }} @@ -123,6 +127,7 @@ const Header = () => { key="community" icon={} onClick={() => { + setRedirectUri(STATIC_ROUTES.COMMUNITY); trackPublicStudies('Community'); setOpenLoginModal(true); }} @@ -228,7 +233,9 @@ const Header = () => { ]} className={style.mainHeader} /> - {openLoginModal && } + {openLoginModal && ( + + )} ); }; diff --git a/src/components/PublicLayout/LoginModal/index.tsx b/src/components/PublicLayout/LoginModal/index.tsx index 4a15d48b..e8a4c993 100644 --- a/src/components/PublicLayout/LoginModal/index.tsx +++ b/src/components/PublicLayout/LoginModal/index.tsx @@ -16,9 +16,10 @@ const { Title } = Typography; type LoginModalProps = { isOpen: boolean; onClose: () => void; + redirectUri?: string; }; -const LoginModal = ({ isOpen, onClose }: LoginModalProps) => { +const LoginModal = ({ isOpen, onClose, redirectUri }: LoginModalProps) => { const { keycloak } = useKeycloak(); const query = useQueryParams(); @@ -26,7 +27,7 @@ const LoginModal = ({ isOpen, onClose }: LoginModalProps) => { trackPublicStudies(btnName); const url = keycloak.createLoginUrl({ redirectUri: `${window.location.origin}/${ - query.get(REDIRECT_URI_KEY) || STATIC_ROUTES.STUDIES + redirectUri || query.get(REDIRECT_URI_KEY) || STATIC_ROUTES.STUDIES }`, locale: intl.getInitOptions().currentLocale, }); diff --git a/src/hooks/useQueryParams.tsx b/src/hooks/useQueryParams.tsx index 59debb89..9239bfa6 100644 --- a/src/hooks/useQueryParams.tsx +++ b/src/hooks/useQueryParams.tsx @@ -1,5 +1,3 @@ -const useQueryParams = () => { - return new URLSearchParams(window.location.search); -}; +const useQueryParams = () => new URLSearchParams(window.location.search); -export default useQueryParams; \ No newline at end of file +export default useQueryParams; diff --git a/src/views/PublicStudies/components/PageContent/index.tsx b/src/views/PublicStudies/components/PageContent/index.tsx index d7fa42f3..dcf2e44d 100644 --- a/src/views/PublicStudies/components/PageContent/index.tsx +++ b/src/views/PublicStudies/components/PageContent/index.tsx @@ -17,7 +17,9 @@ const { Title } = Typography; const PageContent = () => { const [searchValue, setSearchValue] = useState(''); const [openLoginModal, setOpenLoginModal] = useState(false); + const [redirectUri, setRedirectUri] = useState(); const manageLoginModal = (isOpen: boolean) => setOpenLoginModal(isOpen); + const manageRedirectUri = (uri: string) => setRedirectUri(uri); const { stats, isFetchingStats } = useGlobals(); const { studiesParticipants = [] } = stats || {}; @@ -43,7 +45,7 @@ const PageContent = () => { } }; - const defaultColumns = getColumns({ manageLoginModal }); + const defaultColumns = getColumns({ manageLoginModal, manageRedirectUri }); return ( @@ -83,7 +85,11 @@ const PageContent = () => { } /> {openLoginModal && ( - manageLoginModal(false)} /> + manageLoginModal(false)} + redirectUri={redirectUri} + /> )} ); diff --git a/src/views/PublicStudies/utils.tsx b/src/views/PublicStudies/utils.tsx index c21cfadf..a1e7208b 100644 --- a/src/views/PublicStudies/utils.tsx +++ b/src/views/PublicStudies/utils.tsx @@ -10,6 +10,7 @@ import { DataCategory, hasDataCategory } from 'views/Studies'; import { TABLE_EMPTY_PLACE_HOLDER } from 'common/constants'; import { IStudiesParticipants } from 'services/api/arranger/models'; +import { STATIC_ROUTES } from 'utils/routes'; import style from './index.module.css'; @@ -18,9 +19,13 @@ export const TABLE_ID = 'public-studies'; type ColumnsProps = { manageLoginModal: (isOpen: boolean) => void; + manageRedirectUri: (uri: string) => void; }; -export const getColumns = ({ manageLoginModal }: ColumnsProps): ProColumnType[] => [ +export const getColumns = ({ + manageLoginModal, + manageRedirectUri, +}: ColumnsProps): ProColumnType[] => [ { key: 'is_harmonized', iconTitle: , @@ -58,7 +63,16 @@ export const getColumns = ({ manageLoginModal }: ColumnsProps): ProColumnType manageLoginModal(true)}>{study_code}, + render: (study_code: string) => ( + { + manageRedirectUri(STATIC_ROUTES.STUDIES); + manageLoginModal(true); + }} + > + {study_code} + + ), }, { key: 'study_name', @@ -147,7 +161,14 @@ export const getColumns = ({ manageLoginModal }: ColumnsProps): ProColumnType manageLoginModal(true)}>{numberWithCommas(participantCount)} + { + manageRedirectUri(STATIC_ROUTES.DATA_EXPLORATION_PARTICIPANTS); + manageLoginModal(true); + }} + > + {numberWithCommas(participantCount)} + ) : ( participantCount || TABLE_EMPTY_PLACE_HOLDER ); @@ -160,7 +181,14 @@ export const getColumns = ({ manageLoginModal }: ColumnsProps): ProColumnType manageLoginModal(true)}>{numberWithCommas(fileCount)} + { + manageRedirectUri(STATIC_ROUTES.DATA_EXPLORATION_DATAFILES); + manageLoginModal(true); + }} + > + {numberWithCommas(fileCount)} + ) : ( fileCount || TABLE_EMPTY_PLACE_HOLDER );