Skip to content

Commit

Permalink
Merge pull request #1344 from cityofaustin/15130_vze_date_wsod
Browse files Browse the repository at this point in the history
Fix WSOD in VZE when interacting with data widgets on crash listing page
  • Loading branch information
roseeichelmann authored Jan 26, 2024
2 parents 93308c0 + 74e8b9a commit 96c7dd2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions atd-vze/src/Components/GridDateRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ const GridDateRange = ({

/**
* Returns a date in a valid SQL format.
* @param {string} date - The string to be transformed
* @param {string} fallbackValue - The value to use if the formattedDate is invalid
* @param {Date} date - The date object to be formatted
* @param {string} fallbackValue - The value to use if date is null
* @returns {string}
*/
const formatDate = (date, fallbackValue) => {
let formattedDate = format(date, "yyyy-MM-dd");
const formattedDate = date
? format(date, "yyyy-MM-dd")
: format(new Date(fallbackValue), "yyyy-MM-dd");

if (formattedDate === "Invalid date") {
formattedDate = format(fallbackValue, "yyyy-MM-dd");
}
return formattedDate;
};

Expand Down Expand Up @@ -114,6 +113,7 @@ const GridDateRange = ({
// Prevent user from selecting start date after current date
maxDate={maxDate}
minDate={minDate}
strictParsing={true}
/>
<span>{" to "}</span>
<DatePicker
Expand All @@ -126,6 +126,7 @@ const GridDateRange = ({
// Prevent user from selecting date before startDate (chosen in first DatePicker) or after current date
minDate={startDate}
maxDate={maxDate}
strictParsing={true}
/>
</StyledDatePicker>
</>
Expand Down

0 comments on commit 96c7dd2

Please sign in to comment.