Skip to content

Commit

Permalink
feat: adding loading message during fetches
Browse files Browse the repository at this point in the history
  • Loading branch information
katiestahl committed Nov 15, 2023
1 parent 2917cc6 commit ce341ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { getGenomicCoords, getExonCoords } from "../../../services/main";
import {
CoordsUtilsResponse,
GenomicData,
GetGeneTranscriptsResponse,
} from "../../../services/ResponseModels";
import StrandSwitch from "../../main/shared/StrandSwitch/StrandSwitch";
import TabHeader from "../../main/shared/TabHeader/TabHeader";
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/Utilities/GetSequence/GetSequence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ import HelpTooltip from "../../main/shared/HelpTooltip/HelpTooltip";
import { HelpPopover } from "../../main/shared/HelpPopover/HelpPopover";
import TabHeader from "../../main/shared/TabHeader/TabHeader";
import TabPaper from "../../main/shared/TabPaper/TabPaper";
import LoadingMessage from "../../main/shared/LoadingMessage/LoadingMessage";

const GetSequenceIds: React.FC = () => {
const [inputSequence, setInputSequence] = useState<string>("");
const [helperText, setHelperText] = useState<string>("");
const [refseqId, setRefseqId] = useState<string>("");
const [ga4ghId, setGa4ghId] = useState<string>("");
const [aliases, setAliases] = useState<string[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);

useEffect(() => {
if (inputSequence) {
setIsLoading(true);
getSequenceIds(inputSequence).then((sequenceIdsResponse) => {
if (sequenceIdsResponse.warnings) {
setHelperText("Unrecognized sequence");
setRefseqId("");
setGa4ghId("");
setAliases([]);
setIsLoading(false);
} else {
if (sequenceIdsResponse.refseq_id) {
setRefseqId(sequenceIdsResponse.refseq_id);
Expand All @@ -40,6 +44,7 @@ const GetSequenceIds: React.FC = () => {
setAliases(sequenceIdsResponse.aliases);
}
setHelperText("");
setIsLoading(false);
}
});
}
Expand Down Expand Up @@ -184,7 +189,7 @@ const GetSequenceIds: React.FC = () => {
</Box>
);

const renderedIdInfo = (
const renderedIdInfo = isLoading ? (<LoadingMessage />) : (
<Box className={classes.sequenceIdResult}>
<Box className={classes.idsContainer}>
<Box>
Expand Down

0 comments on commit ce341ee

Please sign in to comment.