- Linting... Prettier...
This commit is contained in:
@@ -2,11 +2,7 @@ import { List } from 'immutable';
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
FlatList,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { FlatList, Text, View } from 'react-native';
|
||||
|
||||
import { SORT_MODES, AUCTION_VIEW_MODES } from '../constants/constants.js';
|
||||
|
||||
@@ -16,70 +12,67 @@ import AuctionListItem from '../containers/Auction/AuctionListItem.js';
|
||||
//import styles from './Marketplace.styles.js';
|
||||
|
||||
export default class Marketplace extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
changeFilter: PropTypes.func,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
fetchItems: PropTypes.func.isRequired,
|
||||
fetchStatus: PropTypes.func.isRequired,
|
||||
items: PropTypes.oneOfType([
|
||||
PropTypes.array,
|
||||
PropTypes.instanceOf(List),
|
||||
]),
|
||||
};
|
||||
}
|
||||
static get propTypes() {
|
||||
return {
|
||||
changeFilter: PropTypes.func,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
fetchItems: PropTypes.func.isRequired,
|
||||
fetchStatus: PropTypes.func.isRequired,
|
||||
items: PropTypes.oneOfType([PropTypes.array, PropTypes.instanceOf(List)]),
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
changeFilter: () => { console.log('Change Filter Default Prop', arguments); },
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
static get defaultProps() {
|
||||
return {
|
||||
changeFilter: () => {
|
||||
console.log('Change Filter Default Prop', arguments);
|
||||
},
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.changeFilter = this.changeFilter.bind(this);
|
||||
this.changeViewMode = this.changeViewMode.bind(this);
|
||||
this.changeFilter = this.changeFilter.bind(this);
|
||||
this.changeViewMode = this.changeViewMode.bind(this);
|
||||
|
||||
this.state = {
|
||||
sort: SORT_MODES.TITLE_ASC,
|
||||
view: AUCTION_VIEW_MODES.ALL,
|
||||
};
|
||||
}
|
||||
this.state = {
|
||||
sort: SORT_MODES.TITLE_ASC,
|
||||
view: AUCTION_VIEW_MODES.ALL,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchStatus();
|
||||
this.props.fetchItems();
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.fetchStatus();
|
||||
this.props.fetchItems();
|
||||
}
|
||||
|
||||
changeFilter(filter) {
|
||||
this.props.changeFilter('auction', filter);
|
||||
}
|
||||
changeFilter(filter) {
|
||||
this.props.changeFilter('auction', filter);
|
||||
}
|
||||
|
||||
_keyExtractor = (item, index) => `${item._id}_${index}`;
|
||||
_keyExtractor = (item, index) => `${item._id}_${index}`;
|
||||
|
||||
_renderAuctionListItem = ({ item }) => <AuctionListItem item={item} />;
|
||||
_renderAuctionListItem = ({ item }) => <AuctionListItem item={item} />;
|
||||
|
||||
render() {
|
||||
const { items } = this.props;
|
||||
const { sort, view } = this.state;
|
||||
render() {
|
||||
const { items } = this.props;
|
||||
const { sort, view } = this.state;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<FilterBar
|
||||
changeFilterer={this.changeFilter}
|
||||
/>
|
||||
{items.size > 0 && (
|
||||
<FlatList
|
||||
data={items}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderAuctionListItem}
|
||||
contentContainerStyle={styles.itemListContentContainer}
|
||||
style={styles.itemList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<FilterBar changeFilterer={this.changeFilter} />
|
||||
{items.size > 0 && (
|
||||
<FlatList
|
||||
data={items}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderAuctionListItem}
|
||||
contentContainerStyle={styles.itemListContentContainer}
|
||||
style={styles.itemList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user