broke out routes from App.jsx, and added handleShowRender for static methods
This commit is contained in:
parent
9fea56c8a2
commit
14740341e3
14 changed files with 141 additions and 35 deletions
|
@ -4,6 +4,7 @@ import { CHANNEL, ASSET_LITE, ASSET_DETAILS } from 'constants/show_request_types
|
|||
|
||||
// basic request parsing
|
||||
export function handleShowPageUri (params) {
|
||||
console.log('dispatching handleShowpageUri');
|
||||
return {
|
||||
type: actions.HANDLE_SHOW_URI,
|
||||
data: params,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Request from 'utils/request';
|
||||
const { site: { host } } = require('../../config/speechConfig.js');
|
||||
|
||||
export function getLongClaimId (name, modifier) {
|
||||
// console.log('getting long claim id for asset:', name, modifier);
|
||||
|
@ -15,25 +16,23 @@ export function getLongClaimId (name, modifier) {
|
|||
body['claimName'] = name;
|
||||
const params = {
|
||||
method : 'POST',
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: JSON.stringify(body),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body : JSON.stringify(body),
|
||||
};
|
||||
// create url
|
||||
const url = `/api/claim/long-id`;
|
||||
const url = `${host}/api/claim/long-id`;
|
||||
// return the request promise
|
||||
return Request(url, params);
|
||||
};
|
||||
|
||||
export function getShortId (name, claimId) {
|
||||
// console.log('getting short id for asset:', name, claimId);
|
||||
const url = `/api/claim/short-id/${claimId}/${name}`;
|
||||
const url = `${host}/api/claim/short-id/${claimId}/${name}`;
|
||||
return Request(url);
|
||||
};
|
||||
|
||||
export function getClaimData (name, claimId) {
|
||||
// console.log('getting claim data for asset:', name, claimId);
|
||||
const url = `/api/claim/data/${name}/${claimId}`;
|
||||
const url = `${host}/api/claim/data/${name}/${claimId}`;
|
||||
return Request(url);
|
||||
};
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
import Request from 'utils/request';
|
||||
import request from '../utils/request';
|
||||
const { site: { host } } = require('../../config/speechConfig.js');
|
||||
|
||||
export function getChannelData (name, id) {
|
||||
console.log('getting channel data for channel:', name, id);
|
||||
if (!id) id = 'none';
|
||||
const url = `/api/channel/data/${name}/${id}`;
|
||||
const url = `${host}/api/channel/data/${name}/${id}`;
|
||||
return request(url);
|
||||
};
|
||||
|
||||
export function getChannelClaims (name, longId, page) {
|
||||
console.log('getting channel claims for channel:', name, longId);
|
||||
if (!page) page = 1;
|
||||
const url = `/api/channel/claims/${name}/${longId}/${page}`;
|
||||
const url = `${host}/api/channel/claims/${name}/${longId}/${page}`;
|
||||
return Request(url);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import Request from 'utils/request';
|
||||
const { site: { host } } = require('../../config/speechConfig.js');
|
||||
|
||||
export function checkFileAvailability (name, claimId) {
|
||||
const url = `/api/file/availability/${name}/${claimId}`;
|
||||
const url = `${host}/api/file/availability/${name}/${claimId}`;
|
||||
return Request(url);
|
||||
}
|
||||
|
||||
export function triggerClaimGet (name, claimId) {
|
||||
const url = `/api/claim/get/${name}/${claimId}`;
|
||||
const url = `${host}/api/claim/get/${name}/${claimId}`;
|
||||
return Request(url);
|
||||
}
|
||||
|
|
15
react/app.js
15
react/app.js
|
@ -1,20 +1,13 @@
|
|||
import React from 'react';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import PublishPage from 'components/PublishPage';
|
||||
import AboutPage from 'components/AboutPage';
|
||||
import LoginPage from 'containers/LoginPage';
|
||||
import ShowPage from 'containers/ShowPage';
|
||||
import FourOhFourPage from 'components/FourOhFourPage';
|
||||
import routes from './routes';
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<Switch>
|
||||
<Route exact path='/' component={PublishPage} />
|
||||
<Route exact path='/about' component={AboutPage} />
|
||||
<Route exact path='/login' component={LoginPage} />
|
||||
<Route exact path='/:identifier/:claim' component={ShowPage} />
|
||||
<Route exact path='/:claim' component={ShowPage} />
|
||||
<Route component={FourOhFourPage} />
|
||||
{routes.map((route, index) => (
|
||||
<Route key={index}{...route} />
|
||||
))}
|
||||
</Switch>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -3,10 +3,15 @@ import ErrorPage from 'components/ErrorPage';
|
|||
import ShowAssetLite from 'components/ShowAssetLite';
|
||||
import ShowAssetDetails from 'components/ShowAssetDetails';
|
||||
import ShowChannel from 'components/ShowChannel';
|
||||
import { handleShowPageUri } from 'actions/show';
|
||||
|
||||
import { CHANNEL, ASSET_LITE, ASSET_DETAILS } from 'constants/show_request_types';
|
||||
|
||||
class ShowPage extends React.Component {
|
||||
static fetchData (store, match) {
|
||||
console.log('the store:', store);
|
||||
return store.dispatch(handleShowPageUri(match.params));
|
||||
}
|
||||
componentDidMount () {
|
||||
this.props.handleShowPageUri(this.props.match.params);
|
||||
}
|
||||
|
|
33
react/routes.js
Normal file
33
react/routes.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import PublishPage from 'components/PublishPage';
|
||||
import AboutPage from 'components/AboutPage';
|
||||
import LoginPage from 'containers/LoginPage';
|
||||
import ShowPage from 'containers/ShowPage';
|
||||
import FourOhFourPage from 'components/FourOhFourPage';
|
||||
|
||||
const routes = [
|
||||
{ path : '/',
|
||||
exact : true,
|
||||
component: PublishPage,
|
||||
},
|
||||
{ path : '/about',
|
||||
exact : true,
|
||||
component: AboutPage,
|
||||
},
|
||||
{ path : '/login',
|
||||
exact : true,
|
||||
component: LoginPage,
|
||||
},
|
||||
{ path : '/:identifier/:claim',
|
||||
exact : true,
|
||||
component: ShowPage,
|
||||
},
|
||||
{ path : '/:claim',
|
||||
exact : true,
|
||||
component: ShowPage,
|
||||
},
|
||||
{
|
||||
component: FourOhFourPage,
|
||||
},
|
||||
];
|
||||
|
||||
export default routes;
|
|
@ -1,3 +1,5 @@
|
|||
import 'cross-fetch/polyfill';
|
||||
|
||||
/**
|
||||
* Parses the JSON returned by a network request
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue