Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #432 from davidradl/git427
Browse files Browse the repository at this point in the history
Git427 add validation
  • Loading branch information
davidradl authored Apr 29, 2022
2 parents f09cab1 + 383e1c5 commit 4f12c25
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ export default function DateTimePicker(props) {
// TODO localise
return "mm/dd/yyyy";
};
// asOfDateTimeStr={instancesContext.asOfDateTimeStr}

// onTimeChange={instancesContext.onAsOfTimeChange}
// dateValue={instancesContext.asOfDate}
// timeValue={instancesContext.asOfTimeStr}
// invalidTime={instancesContext.invalidTime}
// invalidDate={instancesContext.invalidDate}
// isTimeDisabled={instancesContext.isTimeDisabled}

return (
<div className="flexcontainer-column">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import "./instance-retriever.scss";

export default function HistoricalDateTime() {
const instancesContext = useContext(InstancesContext);
const [errorMessage, setErrorMessage] = useState("");
const onErrorMessage = (msg) => {
setErrorMessage(msg);
};

return (
<div>
Expand All @@ -33,9 +29,11 @@ export default function HistoricalDateTime() {
<DateTimePicker
dateLabel="As of Date"
timeLabel="As of Time"
onDateTimeMessage={onErrorMessage}
/>
{errorMessage}
{ instancesContext.asOfDate === undefined &&
<div style={{ color: "red" }}> Please input a date for histrorical queries </div>
}

</div>
) }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,18 @@ export default function InstanceSearch(props) {
setStatus("cancelled");
}
};
const isQueryDisabled = () => {
let isDisabled = false;
if (instancesContext.useHistoricalQuery) {
if (
instancesContext.asOfDateTimeForQueries === undefined ||
instancesContext.invalidTime
) {
isDisabled = true;
}
}
return isDisabled;
};


/*
Expand Down Expand Up @@ -562,7 +574,7 @@ export default function InstanceSearch(props) {
onChange = { updatedSearchResultLimit } >
</input>

<button className="retrieval-button" onClick = { searchForInstances } >
<button disabled={isQueryDisabled()} className="retrieval-button" onClick = { searchForInstances } >
Search for instances
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ const InstancesContextProvider = (props) => {
*/
const [gens, setGens] = useState([]);
const [guidToGenId, setGuidToGenId] = useState({});
// /*
// * As of Date - the date part of date time as a string
// */
// const [asOfDateStr, setAsOfDateStr] = useState();



/**
* Switch for using historical state
*/
Expand Down Expand Up @@ -1541,6 +1536,7 @@ const InstancesContextProvider = (props) => {
invalidDate,
isTimeDisabled,
useHistoricalQuery,
asOfDate,
onHistoricalQueryChange,
setGuidToGenId,
setFocus,
Expand Down

0 comments on commit 4f12c25

Please sign in to comment.