Skip to content

Commit

Permalink
added catch if no optimized route available
Browse files Browse the repository at this point in the history
  • Loading branch information
sam9116 committed Jun 29, 2024
1 parent 88279bc commit c960624
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/BaseInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ const BaseInput = forwardRef(({ setConcerts,
//now filter out the ones that don't make chronological sense
allCombinationOfConcerts = allCombinationOfConcerts.filter(isChronological);

if (allCombinationOfConcerts.length < 1) {
alert(`Unable to schedule a plan for the artist concerts you want to go, their schedules conflict with each other`);
//remove the last attempted artist that was causing problem and run the optimization again
generateOptimizedConcertRoute(allConcerts,userLocation, artistWishlist.pop());
}

//now sort the remaining by max distance traveled
allCombinationOfConcerts = allCombinationOfConcerts.sort((a, b) => {
return getTotalDistance(a, userLocation) - getTotalDistance(b, userLocation);
Expand Down

0 comments on commit c960624

Please sign in to comment.