Skip to content

Commit

Permalink
Merge pull request #75 from concord-consortium/187533021-station-message
Browse files Browse the repository at this point in the history
updates no data received message
  • Loading branch information
bacalj authored Jul 26, 2024
2 parents d2ca5b8 + 72bb2b5 commit 44b11fa
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,24 @@ export const App = () => {
const maxDate = endDate || new Date(Date.now());
guaranteeGlobal(globalMinDate, Number(minDate)/1000);
guaranteeGlobal(globalMaxDate, Number(maxDate)/1000);
}, [endDate, startDate, weatherStations]);
if (weatherStation && (!startDate || !endDate)) {
setStatus({
status: "error",
message: "Select a date range",
icon: <WarningIcon/>
});
}
// if the start date of the weather station is after the user's requested end date, then the station is inactive
const stationMinDate = new Date(weatherStation?.mindate || globalMinDate);
const stationNotActiveYet = stationMinDate > maxDate;
if (stationNotActiveYet) {
setStatus({
status: "station-error",
message: "Station was inactive for date range",
icon: <WarningIcon/>
});
}
}, [endDate, startDate, weatherStations, weatherStation]);

const stationSelectionHandler = async(req: any) =>{
if (req.values.operation === "selectCases") {
Expand Down Expand Up @@ -237,7 +254,7 @@ export const App = () => {
setIsFetching(false);
setStatus({
status: "error",
message: "No data retrieved",
message: "No data retrieved. Change frequency or station.",
icon: <WarningIcon/>
});
}
Expand Down

0 comments on commit 44b11fa

Please sign in to comment.