Commit 941e53fc authored by Maksym Tishchenko's avatar Maksym Tishchenko
Browse files

Support URL by accessionNumber

parent af14fa4c
......@@ -39,6 +39,13 @@ class AccessionDetailsPage extends React.Component<AccessionDetailsPageProps & W
cartItems: LocalStorageCart.getCartItemsLS(),
};
public componentDidUpdate(prevProps) {
if (prevProps.match.params.uuid !== this.props.match.params.uuid) {
console.log('Loading data');
this.loadData(this.props.match.params.uuid);
}
}
public componentDidMount() {
this.loadData(this.props.match.params.uuid);
if (typeof window !== 'undefined') {
......
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
// hookfilter
import useAccessionPageLoad from 'accession/hook/useAccessionPageLoad';
// ui
import PageTitle from 'ui/common/PageTitle';
import AccessionTable from 'accession/c/AccessionTable';
import {history} from "ui/core/App";
import NotFound from 'ui/core/NotFound';
interface PassportPageProps {
match: any;
}
const PassportPage = ({match}: PassportPageProps) => {
// util
const { t } = useTranslation()
// redux
const initialFilter = useSelector((state: any) => state?.appConfig?.config?.filter)
const filter = { ...initialFilter, accessionNumber: { eq: match.params.accessionNumber }};
// custom
const accessionPage = useAccessionPageLoad({initialFilterCode: "", initialFilter: filter});
let { accessions } = accessionPage;
const { loadData } = accessionPage;
React.useEffect(() => {
loadData(filter, {}).then((data) => {
accessions = data
})
}, [match])
if (accessions?.totalElements === 1) {
// Open details page
history.replace(`/a/${ accessions.content[0].uuid }`);
}
if (accessions?.totalElements === 0) {
// Not found
return <NotFound/ >
}
return (
<>
<PageTitle title={ t('pagetitle.accessionList') }/>
<h1 className="d-flex justify-content-between align-items-center">
{ t('estimatedNumberOfItems', {
count: accessions?.totalElements,
what: t('accession.model', { count: accessions?.totalElements })
}) }
</h1>
<AccessionTable accessions={ accessions } loadData={ loadData } noRedirect/>
</>
);
}
export default PassportPage;
......@@ -22,6 +22,7 @@ import SubsetListPage from "subset/SubsetListPage";
import SubsetDetailsPage from "subset/SubsetDetailsPage";
import DatasetListPage from "dataset/DatasetListPage";
import DatasetDetailsPage from "dataset/DatasetDetailsPage";
import PassportPage from "accession/PassportPage";
const hashHistory = createHashHistory({});
......@@ -46,6 +47,7 @@ class App extends React.Component<AppProps & WithTranslation & WithConfig, any>
<div>
<Switch>
<Route path="/a/:uuid" exact component={ AccessionDetails } />
<Route path="/a/passport/:accessionNumber" exact component={ PassportPage } />
<Route path="/" exact component={ AccessionList }/>
<Route path="/api-info" exact component={ ApiInfoPage }/>
{ shoppingCart.enabled && <Route path="/cart/" exact component={ CartPage }/> }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment