Skip to content

Commit

Permalink
Merge pull request #30 from BU-Spark/deployBranch
Browse files Browse the repository at this point in the history
Deploy branch
  • Loading branch information
jasonjiang9142 authored Jun 18, 2024
2 parents b03c11e + 2c5b4f8 commit dc962d2
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions client/src/pages/upcomingElections/deadlineToRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ type Props = {
deadline: String;
}

interface ElectionDateAttributes {
ElectionDate: string;
}

interface ElectionDateObject {
attributes: ElectionDateAttributes;
}


export default function DeadlineToRegister() {
const [isLoading, setIsLoading] = useState(true);
const [electionDates, setElectionDates] = useState([])
Expand Down Expand Up @@ -47,12 +56,13 @@ export default function DeadlineToRegister() {
setIsLoading(false);

const sortedDates = electionDates
.map((date: string) => new Date(date.attributes.ElectionDate))
.sort((a, b) => a - b);
.map((dateObj: ElectionDateObject) => new Date(dateObj.attributes.ElectionDate))
.sort((a, b) => a.getTime() - b.getTime());


let minDate = sortedDates[0];

var minDate = new Date(Math.min.apply(null, sortedDates));
sortedDates.map(date => {
sortedDates.forEach(date => {
if (date < minDate) {
minDate = date;
}
Expand All @@ -69,7 +79,7 @@ export default function DeadlineToRegister() {
year: 'numeric'
});

setDisplayRegistrationDate(formattedRegistrationDate)
setDisplayRegistrationDate(formattedRegistrationDate);
}
}, [electionDates]);

Expand Down

0 comments on commit dc962d2

Please sign in to comment.