Skip to content

Commit f9f6aed

Browse files
authored
Merge pull request #218 from CodeForPhilly/feature/volunteer-activity
Volunteer activity now included on 360 view
2 parents d74b453 + 199356b commit f9f6aed

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

src/client/src/pages/DataView360/DataView360.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import CircularProgress from '@material-ui/core/CircularProgress';
1818
import styles from "./styles/DataView360.module.css";
1919
import _ from 'lodash';
20+
import moment from 'moment';
2021
import SearchBar from './components/SearchBar';
2122
import ContactInfo from './components/ContactInfo';
2223
import Volunteer from './components/Volunteer';
@@ -75,6 +76,7 @@ class DataView360 extends Component {
7576
showSearchBar: true
7677
}
7778

79+
this.extractVolunteerActivity = this.extractVolunteerActivity.bind(this);
7880
this.handleGetParticipant = this.handleGetParticipant.bind(this);
7981
this.handleSearchChange = this.handleSearchChange.bind(this);
8082
}
@@ -95,6 +97,20 @@ class DataView360 extends Component {
9597
});
9698
}
9799

100+
extractVolunteerActivity() {
101+
const volgistics = _.find(this.state.participantData.contact_details, {"source_type": "volgistics"}) || {};
102+
let volunteerActivity = {"life_hours": 0, "ytd_hours": 0, "start_date": "N/A"}
103+
104+
if (Object.keys(volgistics).length > 0) {
105+
const volgisticsJson = JSON.parse(volgistics.json);
106+
volunteerActivity = _.pick(volgisticsJson, Object.keys(volunteerActivity));
107+
if (volunteerActivity["start_date"] !== "") {
108+
volunteerActivity["start_date"] = moment(volunteerActivity["start_date"], "MM-DD-YYYY").format("YYYY-MM-DD");
109+
}
110+
}
111+
return volunteerActivity;
112+
}
113+
98114
renderParticipantsTable() {
99115
const {classes} = this.props;
100116
const tableRowColors = [classes.tableRowEven, classes.tableRowOdd]
@@ -200,7 +216,7 @@ class DataView360 extends Component {
200216
</Grid>
201217
<Donations donations={_.get(this.state, 'participantData.donations')}/>
202218
<Adoptions adoptions={_.get(this.state, 'participantData.adoptions')}/>
203-
<Volunteer volunteer={_.get(this.state, 'participantData.shifts')}
219+
<Volunteer volunteer={this.extractVolunteerActivity()}
204220
volunteerShifts={_.get(this.state, 'participantData.shifts')}/>
205221

206222
</Paper>)}

src/client/src/pages/DataView360/components/Volunteer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class Volunteer extends Component {
4848

4949
return (
5050
<React.Fragment>
51-
<Container className={styles.volonteer_activity} style={{"marginTop":"1em"}}>
52-
<Typography className={styles.volonteer_activity_title} variant='h4'>Volunteer Activity</Typography>
51+
<Container className={styles.volunteer_activity} style={{"marginTop":"1em"}}>
52+
<Typography className={styles.volunteer_activity_title} variant='h4'>Volunteer Activity</Typography>
5353
<TableContainer className="main_table_container" style={{"marginTop":"1em"}} component={Paper}>
5454
<Table className="main_table">
5555
<TableHead>
@@ -63,16 +63,16 @@ class Volunteer extends Component {
6363
{ this.props.volunteer && (
6464
<StyledTableRow>
6565
<TableCell>{this.props.volunteer.start_date}</TableCell>
66-
<TableCell>{this.props.volunteer.life_hours}</TableCell>
67-
<TableCell>{this.props.volunteer.ytd_hours}</TableCell>
66+
<TableCell>{this.props.volunteer.life_hours.toFixed(2)}</TableCell>
67+
<TableCell>{this.props.volunteer.ytd_hours.toFixed(2)}</TableCell>
6868
</StyledTableRow>
6969
)}
7070
</TableBody>
7171
</Table>
7272
</TableContainer>
7373
</Container>
74-
<Container className={styles.volonteer_history} style={{"marginTop":"1em"}}>
75-
<Typography className={styles.volonteer_history_title} variant='h4'>Volunteer History (Top 3)</Typography>
74+
<Container className={styles.volunteer_history} style={{"marginTop":"1em"}}>
75+
<Typography className={styles.volunteer_history_title} variant='h4'>Volunteer History (Top 3)</Typography>
7676
<TableContainer className="main_table_container" style={{"marginTop":"1em"}} component={Paper} variant='outlined'>
7777
<Table className="main_table">
7878
<TableHead>

src/client/src/pages/DataView360/components/styles/Volunteer.module.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
div.volonteer_activity {
1+
div.volunteer_activity {
22
grid-area: 3 / 2 / 4 / 3;
33
margin-bottom: 40px;
44
padding: 0;
@@ -8,7 +8,7 @@ div.volonteer_activity {
88
overflow: hidden;
99
}
1010

11-
div.volonteer_history {
11+
div.volunteer_history {
1212
grid-area: 4 / 2 / 5 / 3;
1313
margin-bottom: 40px;
1414
padding: 0;
@@ -18,14 +18,14 @@ div.volonteer_history {
1818
overflow: hidden;
1919
}
2020

21-
h4.volonteer_activity_title {
21+
h4.volunteer_activity_title {
2222
position: relative;
2323
margin: 15px 20px;
2424
padding-left: 23px;
2525
font-size: 16px;
2626
text-align: left;
2727
}
28-
h4.volonteer_activity_title::before {
28+
h4.volunteer_activity_title::before {
2929
content: '';
3030
position: absolute;
3131
top: -3px;
@@ -38,14 +38,14 @@ h4.volonteer_activity_title::before {
3838
background-size: contain;
3939
}
4040

41-
h4.volonteer_history_title {
41+
h4.volunteer_history_title {
4242
position: relative;
4343
margin: 15px 20px;
4444
padding-left: 23px;
4545
font-size: 16px;
4646
text-align: left;
4747
}
48-
h4.volonteer_history_title::before {
48+
h4.volunteer_history_title::before {
4949
content: '';
5050
position: absolute;
5151
top: -9px;

0 commit comments

Comments
 (0)