Skip to content

Commit

Permalink
feat(openalex): Add spinner while loading ROR data
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Dec 13, 2024
1 parent caea5d2 commit ff33d5b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions client/src/pages/openalex-affiliations/results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function Affiliations() {
const [filteredAffiliationName, setFilteredAffiliationName] = useState('');
const [filteredAffiliations, setFilteredAffiliations] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [isLoadingRor, setIsLoadingRor] = useState(false);
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
const [isRemoveModalOpen, setIsRemoveModalOpen] = useState(false);
const [ror, setRor] = useState('');
Expand Down Expand Up @@ -298,8 +299,10 @@ export default function Affiliations() {
};

const getCleanRor = async () => {
setIsLoadingRor(true);
const cleanRorData = await getRorData(ror);
setCleanRor(cleanRorData[0]);
setIsLoadingRor(false);
};

const setSelectAffiliations = (affiliationIds) => {
Expand Down Expand Up @@ -568,7 +571,7 @@ export default function Affiliations() {
onChange={(e) => setRor(e.target.value)}
value={ror}
label="ROR"
hint="Enter a valid ROR id and 'check' it with ROR API"
hint='Enter a valid ROR id and "check" it with ROR API'
/>
</Col>
<Col md="3">
Expand All @@ -586,7 +589,7 @@ export default function Affiliations() {
</Row>
<Row>
<Col>
{
{isLoadingRor ? (<Spinner size={48} />) : (
rorMessageType === 'valid' && cleanRor.rorName && cleanRor.rorCountry
&& (
<>
Expand All @@ -602,15 +605,15 @@ export default function Affiliations() {
className="fr-mt-3w"
color="blue-ecume"
disabled={['', 'error'].includes(rorMessageType) || !cleanRor.rorName || !cleanRor.rorCountry}
onClick={() => { addRor(); }}
onClick={() => addRor()}
size="sm"
title="Add ROR"
>
Add this ROR to selected affiliations
</Button>
</>
)
}
)}
</Col>
</Row>
</Container>
Expand Down

0 comments on commit ff33d5b

Please sign in to comment.