added an asset selector

This commit is contained in:
bill bittner 2018-02-14 12:30:30 -08:00
parent 0548906c4d
commit 7a8466ef68
5 changed files with 14 additions and 14 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -1,6 +1,6 @@
import React from 'react';
const AssetTitle = ({title}) => {
const AssetTitle = ({ title }) => {
return (
<div>
<span className="text--large">{title}</span>

7
react/selectors/asset.js Normal file
View 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;