- implementing immutable.js

This commit is contained in:
2019-07-17 03:21:23 -04:00
parent 8ecf036cc4
commit 434a1ded24
39 changed files with 1123 additions and 187 deletions

18
app/containers/Auction.js Normal file
View 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);

View File

@@ -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),
};
}

View File

@@ -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),
};
}