From 004a844e65f403a2487ff2d04733e44c2f7b0373 Mon Sep 17 00:00:00 2001 From: jerem Date: Wed, 27 Nov 2024 10:46:34 +0100 Subject: [PATCH] feat(openalex): Refactor affiliation handling and enhance button interactions --- .../src/pages/openalex-ror/results/index.jsx | 119 ++++++++++-------- 1 file changed, 67 insertions(+), 52 deletions(-) diff --git a/client/src/pages/openalex-ror/results/index.jsx b/client/src/pages/openalex-ror/results/index.jsx index e33c905..9909c0d 100644 --- a/client/src/pages/openalex-ror/results/index.jsx +++ b/client/src/pages/openalex-ror/results/index.jsx @@ -1,6 +1,7 @@ import { Badge, Button, + ButtonGroup, Col, Container, Link, @@ -148,6 +149,8 @@ export default function Affiliations() { useEffect(() => { const get = async () => { + console.log('before get'); + setIsLoadingRorData(true); const addedRors = await Promise.all( addList.map((add) => getRorData(add)), @@ -155,12 +158,13 @@ export default function Affiliations() { const uniqueRorsTmp = {}; addedRors.flat().forEach((addedRor) => { if (!Object.keys(uniqueRors).includes(addedRor.rorId)) { - uniqueRorsTmp[addedRor.rorId] = { ...addedRor, countAffiliations: 0 }; + uniqueRorsTmp[addedRor.rorId] = { ...addedRor, countAffiliations: selectedOpenAlex.length }; } }); setUniqueRors({ ...uniqueRors, ...uniqueRorsTmp }); setIsLoadingRorData(false); }; + get(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [addList]); @@ -265,6 +269,10 @@ export default function Affiliations() { // eslint-disable-next-line react-hooks/exhaustive-deps }, [ror]); + console.log('uniqueRors', uniqueRors); + console.log('selectedOpenAlex', selectedOpenAlex); + console.log('addList', addList); + return ( <>
@@ -414,7 +422,7 @@ export default function Affiliations() { ROR - Name + {/* Name */} Number of affiliations Added by Removed by @@ -441,14 +449,16 @@ export default function Affiliations() { uniqueRor.rorId, ) ? ({` https://ror.org/${uniqueRor.rorId}`}) : (` https://ror.org/${uniqueRor.rorId}`)} - - - {getFlagEmoji(uniqueRor.rorCountry)} - + {/* + */} +
+