Skip to content

Commit a16e42f

Browse files
committed
Issue #327: VolunteerHistory and Donations show most recent 3
1 parent 654a74b commit a16e42f

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/client/src/pages/DataView360/View/components/Donations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const customStyles = theme => ({
2626
}
2727
});
2828

29-
const ROWS_TO_SHOW = 5
29+
const ROWS_TO_SHOW = 3
3030

3131
class Donations extends Component {
3232
constructor(props) {
@@ -57,7 +57,7 @@ class Donations extends Component {
5757

5858
render() {
5959
const {classes} = this.props;
60-
60+
const headerText = `Financial Support Activity (Most Recent ${ROWS_TO_SHOW})`
6161
return (
6262
<Container component={Paper} style={{"marginTop": "1em"}}>
6363
<Typography variant='h5'>
@@ -66,7 +66,7 @@ class Donations extends Component {
6666
<AttachMoneyIcon color='primary' fontSize='inherit'/>
6767
</Grid>
6868
<Grid item>
69-
Financial Support Activity (Top 5)
69+
{headerText}
7070
</Grid>
7171
</Grid>
7272
</Typography>

src/client/src/pages/DataView360/View/components/VolunteerHistory.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const customStyles = theme => ({
2525
},
2626
});
2727

28-
const SHIFTS_TO_SHOW = 5;
28+
const SHIFTS_TO_SHOW = 3;
2929

3030
class VolunteerHistory extends Component {
3131

@@ -34,11 +34,11 @@ class VolunteerHistory extends Component {
3434
return new moment(shift.from);
3535
}).reverse();
3636

37-
const lastShifts = shiftsSorted.slice(shiftsSorted.length - SHIFTS_TO_SHOW, shiftsSorted.length)
38-
37+
const lastShifts = shiftsSorted.slice(0, SHIFTS_TO_SHOW)
3938
const result = _.map(lastShifts, (shift, index) => {
39+
shift.from = (shift.from === "Invalid date") ? "Unknown" : moment(shift.from).format("MM-DD-YYYY")
4040
return(<TableRow key={index}>
41-
<TableCell>{moment(shift.from).format("MM-DD-YYYY")}</TableCell>
41+
<TableCell>{shift.from}</TableCell>
4242
<TableCell>{shift.assignment}</TableCell>
4343
</TableRow>);
4444

@@ -53,7 +53,7 @@ class VolunteerHistory extends Component {
5353
return (
5454
<React.Fragment>
5555
<Container component={Paper} style={{"marginTop": "1em"}}>
56-
<DataTableHeader headerText={"Volunteer History (Top 5)"}
56+
<DataTableHeader headerText={`Volunteer History (Most Recent ${SHIFTS_TO_SHOW})`}
5757
emojiIcon={<TimelineIcon color='primary' fontSize='inherit'/>}
5858
/>
5959
<TableContainer component={Paper} style={{"marginBottom":"1em"}} variant='outlined'>

src/server/api/common_api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ def get_360(matching_id):
9191
for r in volgistics_shifts_query_result:
9292
shifts = dict(r)
9393
# normalize date string
94-
parsed_date_from = dateutil.parser.parse(shifts["from"], ignoretz=True)
95-
normalized_date_from = parsed_date_from.strftime("%Y-%m-%d")
96-
shifts["from"] = normalized_date_from
94+
if shifts["from"]:
95+
parsed_date_from = dateutil.parser.parse(shifts["from"], ignoretz=True)
96+
normalized_date_from = parsed_date_from.strftime("%Y-%m-%d")
97+
shifts["from"] = normalized_date_from
98+
else:
99+
shifts["from"] = "Invalid date"
97100
volgisticsshifts_results.append(shifts)
98101

99102
result['shifts'] = volgisticsshifts_results

0 commit comments

Comments
 (0)