added an asset selector
This commit is contained in:
parent
0548906c4d
commit
7a8466ef68
5 changed files with 14 additions and 14 deletions
|
@ -1,15 +1,14 @@
|
|||
import { connect } from 'react-redux';
|
||||
import View from './view';
|
||||
import { fileRequested } from 'actions/show';
|
||||
import selectAsset from 'selectors/asset';
|
||||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
// select error and status
|
||||
const error = show.displayAsset.error;
|
||||
const status = show.displayAsset.status;
|
||||
// select asset
|
||||
const request = show.requestList[show.request.id];
|
||||
const assetKey = request.key;
|
||||
const asset = show.assetList[assetKey];
|
||||
const asset = selectAsset(show);
|
||||
// return props
|
||||
return {
|
||||
error,
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { connect } from 'react-redux';
|
||||
import View from './view';
|
||||
import selectAsset from 'selectors/asset';
|
||||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
// select asset
|
||||
const request = show.requestList[show.request.id];
|
||||
const assetKey = request.key;
|
||||
const asset = show.assetList[assetKey];
|
||||
const asset = selectAsset(show);
|
||||
// return props
|
||||
return {
|
||||
asset,
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
import { connect } from 'react-redux';
|
||||
import View from './view';
|
||||
import selectAsset from 'selectors/asset';
|
||||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
// select title
|
||||
const request = show.requestList[show.request.id];
|
||||
const assetKey = request.key;
|
||||
const asset = show.assetList[assetKey];
|
||||
let title;
|
||||
if (asset) {
|
||||
title = asset.claimData.title;
|
||||
};
|
||||
const { claimData: { title } } = selectAsset(show);
|
||||
// return props
|
||||
return {
|
||||
title,
|
||||
|
|
7
react/selectors/asset.js
Normal file
7
react/selectors/asset.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
const selectAsset = (show) => {
|
||||
const request = show.requestList[show.request.id];
|
||||
const assetKey = request.key;
|
||||
return show.assetList[assetKey];
|
||||
};
|
||||
|
||||
export default selectAsset;
|
Loading…
Reference in a new issue