- implementing immutable.js
This commit is contained in:
18
app/containers/Auction.js
Normal file
18
app/containers/Auction.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { getItems, getStatus } from '../actions/index.js';
|
||||
|
||||
import { getAuctionItemsAsList } from '../selectors/items.js';
|
||||
|
||||
import Auction from '../screens/Auction.js';
|
||||
|
||||
const matchStateToProps = (state) => ({
|
||||
items: getAuctionItemsAsList(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
fetchItems: () => dispatch(getItems(dispatch)),
|
||||
fetchStatus: () => dispatch(getStatus(dispatch)),
|
||||
});
|
||||
|
||||
export default connect(matchStateToProps, mapDispatchToProps)(Auction);
|
||||
@@ -1,13 +1,15 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { getItemBidCount, getItemPrice } from '../../selectors/auctions.js';
|
||||
|
||||
import AuctionPriceAndBidCount from '../../components/Auction/AuctionPriceAndBidCount.js';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const { bidCount, currentPrice } = getAuctionItemStatus(state, ownProps.id);
|
||||
const { itemId } = ownProps;
|
||||
|
||||
return {
|
||||
bidCount,
|
||||
currentPrice,
|
||||
bidCount: getItemBidCount(state, itemId),
|
||||
currentPrice: getItemPrice(state, itemId),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { isBiddingItem, isWinningItem } from '../../selectors/auctions.js';
|
||||
|
||||
import AuctionPriceAndBidCount from '../../components/Auction/BidStatus.js';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const {
|
||||
bidCount,
|
||||
currentPrice,
|
||||
isBidding,
|
||||
isWinning,
|
||||
} = getAuctionItemStatus(state, ownProps.id);
|
||||
const { itemId } = ownProps;
|
||||
|
||||
return {
|
||||
bidCount,
|
||||
currentPrice,
|
||||
isBidding,
|
||||
isWinning,
|
||||
isBidding: isBiddingItem(state, itemId),
|
||||
isWinning: isWinningItem(state, itemId),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user