Skip to content

Commit

Permalink
Filters out shifts with invalid dates
Browse files Browse the repository at this point in the history
  • Loading branch information
dcstlouis committed May 31, 2021
1 parent a16e42f commit 53ea852
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ const SHIFTS_TO_SHOW = 3;
class VolunteerHistory extends Component {

createShiftRows(shifts) {
const shiftsSorted = _.sortBy(shifts, shift => {
return new moment(shift.from);
const shiftsFiltered = _.filter(shifts, function(s) { return s.from !== "Invalid date"});
const shiftsSorted = _.sortBy(shiftsFiltered, shift => {
return new moment(shift.from).format("YYYY-MM-DD");
}).reverse();

const lastShifts = shiftsSorted.slice(0, SHIFTS_TO_SHOW)

const result = _.map(lastShifts, (shift, index) => {
shift.from = (shift.from === "Invalid date") ? "Unknown" : moment(shift.from).format("MM-DD-YYYY")
shift.from = moment(shift.from).format("YYYY-MM-DD")
return(<TableRow key={index}>
<TableCell>{shift.from}</TableCell>
<TableCell>{shift.assignment}</TableCell>
Expand Down

0 comments on commit 53ea852

Please sign in to comment.