Skip to content

Commit 8017e5c

Browse files
author
Skekacs93
committed
more work on inlines
1 parent 741c047 commit 8017e5c

File tree

3 files changed

+122
-16
lines changed

3 files changed

+122
-16
lines changed

src/components/Inlines.jsx

+103-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,100 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { withStyles } from 'material-ui/styles';
4+
import Icon from 'material-ui/Icon';
5+
import IconButton from 'material-ui/IconButton';
6+
import { gotoProfile } from '../action-creators/global-actions';
7+
8+
import { bindActionCreators } from 'redux';
9+
import { connect } from 'react-redux';
10+
411

512
const styles = theme => ({
613
wrapper: {
7-
borderBottom: `1px solid ${theme.text.secondary}`
14+
borderBottom: `1px solid ${theme.palette.text.secondary}`,
15+
padding: '10px',
16+
height: '50px'
17+
},
18+
content: {
19+
marginTop: '7px',
20+
display: 'inline-block'
21+
},
22+
iconBtn: {
23+
border: `1px solid ${theme.palette.text.secondary}`,
24+
borderRadius: '100%',
25+
width: '40px',
26+
height: '40px'
27+
},
28+
icon: {
29+
fontSize: '32px'
30+
},
31+
nameText: {
32+
fontSize: '20px',
33+
marginLeft: '10px'
34+
},
35+
mainText: {
36+
fontSize: '20px',
37+
position: 'relative',
38+
top: '-10px',
39+
left: '10px'
40+
},
41+
subText: {
42+
display: 'grid',
43+
fontSize: '16px',
44+
color: theme.palette.text.secondary,
45+
marginLeft: '50px',
46+
marginTop: '-16px'
47+
},
48+
actionIcons: {
49+
float: 'right',
50+
display: 'inline-block',
51+
marginTop: '5px'
52+
},
53+
msgIconBtn: {
54+
border: `2px solid blue`,
55+
borderRadius: '100%',
56+
width: '40px',
57+
height: '40px',
58+
marginRight: '5px'
59+
},
60+
msgIcon: {
61+
color: 'blue'
62+
},
63+
removeIconBtn: {
64+
border: `2px solid red`,
65+
borderRadius: '100%',
66+
width: '40px',
67+
height: '40px'
68+
69+
},
70+
removeIcon: {
71+
color: 'red'
872
}
973
})
1074

1175
const UserBaseInline = props => (
1276
<div className={props.classes.wrapper}>
13-
User
77+
<div className={props.classes.content}>
78+
<IconButton
79+
className={props.classes.iconBtn}
80+
onClick={() => props.gotoProfile(props.data.id)}
81+
>
82+
<Icon className={props.classes.icon}>account_circle</Icon>
83+
</IconButton>
84+
<span className={props.classes.nameText}>{props.data.first_name} {props.data.last_name}</span>
85+
</div>
86+
<div className={props.classes.actionIcons}>
87+
<IconButton
88+
className={props.classes.msgIconBtn}
89+
>
90+
<Icon className={props.classes.msgIcon}>message</Icon>
91+
</IconButton>
92+
<IconButton
93+
className={props.classes.removeIconBtn}
94+
>
95+
<Icon className={props.classes.removeIcon}>clear</Icon>
96+
</IconButton>
97+
</div>
1498
</div>
1599
)
16100

@@ -22,10 +106,25 @@ const RewardBaseInline = props => (
22106

23107
const ActivityBaseInline = props => (
24108
<div className={props.classes.wrapper}>
25-
Activity
109+
<div className={props.classes.content}>
110+
<IconButton
111+
className={props.classes.iconBtn}
112+
>
113+
<Icon className={props.classes.icon}>group_work</Icon>
114+
</IconButton>
115+
<span className={props.classes.mainText}>{props.data.name}</span>
116+
<span className={props.classes.subText}>{props.data.playerIds.length} Players</span>
117+
</div>
26118
</div>
27119
)
28120

29-
export const UserInline = withStyles(styles)(UserBaseInline);
121+
const mapDispatchToProps = dispatch => bindActionCreators({
122+
gotoProfile: gotoProfile,
123+
}, dispatch);
124+
125+
export const UserInline = connect(
126+
null,
127+
mapDispatchToProps
128+
)(withStyles(styles)(UserBaseInline));
30129
export const RewardInline = withStyles(styles)(RewardBaseInline);
31130
export const ActivityInline = withStyles(styles)(ActivityBaseInline);

src/components/ListPage.jsx

+18-11
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,31 @@ class ListPage extends React.Component {
2424
}
2525
}
2626

27-
renderItemsBasedOnType() {
27+
renderItems(Component) {
2828
if (this.props.itemType === 'user') {
29-
return this.renderItems(UserInline);
29+
return (
30+
this.props.items.filter((item) => (
31+
(!this.state.searchTerm ||
32+
(item.first_name + " " + item.last_name).toLowerCase().search(this.state.searchTerm.toLowerCase()) >= 0)
33+
)).map((item) => (<UserInline data={item} />))
34+
);
3035
} else if (this.props.itemType === 'reward') {
31-
return this.renderItems(RewardInline);
36+
// TODO FILTERING
37+
return (
38+
this.props.items.map((item) => (<RewardInline data={item} />))
39+
)
3240
} else if (this.props.itemType === 'activity') {
33-
return this.renderItems(ActivityInline);
41+
return (
42+
this.props.items.filter((item) => (
43+
(!this.state.searchTerm ||
44+
(item.name + " " + item.sport).toLowerCase().search(this.state.searchTerm.toLowerCase()) >= 0)
45+
)).map((item) => (<ActivityInline data={item} />))
46+
);
3447
}
3548
}
3649

37-
renderItems(Component) {
38-
return this.props.items.map((item) => (
39-
<Component data={item} />
40-
));
41-
}
42-
4350
render() {
44-
let items = this.renderItemsBasedOnType()
51+
let items = this.renderItems()
4552

4653
if (this.props.items.length === 0) {
4754
items = (<div>No Results</div>);

src/modules/reducer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function users(state = initState, action) {
2929
case actionTypes.GET_USER_INFO:
3030
// given a user id get all info, including activities
3131
const userId = parseInt(action.userId);
32-
32+
console.log("LOADING USER INFO: ", userId);
3333
// get basic user info
3434
state = state.set('userInfo', state.get('users').find((obj) => obj.get('id') === userId));
3535

0 commit comments

Comments
 (0)