App.tsx 1.62 KB
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1
2
3
4
5
6
7
import React from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import NotFound from './NotFound';
import ApiInfoPage from './ApiInfoPage';
import AccessionList from './AccessionListPage';
import AccessionDetails from './AccessionDetailsPage';
import { createHashHistory } from 'history';
Oleksii Savran's avatar
Oleksii Savran committed
8
import CartPage from './CartPage';
Matija Obreza's avatar
Matija Obreza committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

const hashHistory = createHashHistory({});

interface IAppProps extends React.ClassAttributes<any> {
  apiUrl: string;
  filter: object;
}

export default class App extends React.Component<IAppProps, any> {
  public render() {
    const { apiUrl } = this.props;
    console.log('Using filter', this.props.filter);
    return (
      <>
        <Router>
          <div>
            <Switch>
              <Route path="/a/:uuid" exact render={ (props) => <AccessionDetails { ...props } apiUrl={ apiUrl } /> } />
              <Route path="/" exact render={ (props) => <AccessionList { ...props } filter={ this.props.filter }/> }/>
              <Route path="/api-info" exact component={ ApiInfoPage }/>
Oleksii Savran's avatar
Oleksii Savran committed
29
              <Route path="/cart/" exact component={ CartPage }/>
Matija Obreza's avatar
Matija Obreza committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
              <Route component={ NotFound }/>
            </Switch>

            <div style={ { marginTop: 20, textAlign: 'center', fontSize: '10pt' } }>
              <img style={ { height: '1.2em', verticalAlign: 'text-bottom' } } src={ `${apiUrl}/html/1/images/GENESYS-ICON.svg` } alt="Genesys PGR" />
              <> Powered by <a target="_blank" title="Data sourced from Genesys" href={ apiUrl }>Genesys PGR</a></>
            </div>
          </div>
        </Router>
      </>
    );
  };
}

export { hashHistory as history};