Skip to content

Commit

Permalink
feat(openalex): Add searched affiliations in the search part
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Nov 15, 2024
1 parent 7420e46 commit f41116d
Showing 1 changed file with 54 additions and 26 deletions.
80 changes: 54 additions & 26 deletions client/src/pages/openalex-ror/results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default function Affiliations() {
});
setBody(queryParams);
};

getData();
}, [searchParams]);

Expand Down Expand Up @@ -189,32 +188,62 @@ export default function Affiliations() {
{!isFetching && isFetched && (
<Row>
<Col md={2}>
<TagGroup className="cursor-pointer" onClick={() => navigate(`/${pathname.split('/')[1]}/search${search}`)}>
<Tag color="blue-ecume" key="tag-years" size="sm">
{`${body.startYear} - ${body.endYear}`}
</Tag>
<br />
{body?.affiliationStrings?.map((tag) => (
<Tag
className={tag.length < VITE_APP_TAG_LIMIT ? 'scratched' : ''}
color="blue-ecume"
key={`tag-${tag}`}
size="sm"
>
{tag}
<Row>
<Col>
Start year:
<Tag color="blue-ecume" key="tag-year-start" size="sm">
{searchParams.get('startYear') ?? '2023'}
</Tag>
))}
<br />
{body?.rors?.map((tag) => (
<Tag
color="blue-ecume"
key={`tag-${tag}`}
size="sm"
>
{tag}
</Col>
</Row>
<Row>
<Col>
End year:
<Tag color="blue-ecume" key="tag-year-end" size="sm">
{searchParams.get('endYear') ?? '2023'}
</Tag>
))}
</TagGroup>
</Col>
</Row>
<Row>
<Col>
Affiliations:
{searchParams.getAll('affiliations').map((affiliation) => {
if (isRor(affiliation)) {
return (
<Row>
<Tag
className={affiliation.length < VITE_APP_TAG_LIMIT ? 'scratched' : ''}
color="brown-caramel"
key={`tag-${affiliation}`}
size="sm"
>
{affiliation}
</Tag>
</Row>
);
}
return (
<Row>
<Tag
className={affiliation.length < VITE_APP_TAG_LIMIT ? 'scratched' : ''}
color="brown-cafe-creme"
key={`tag-${affiliation}`}
size="sm"
>
{affiliation}
</Tag>
</Row>
)
})}
</Col>
</Row>
<Row>
<Button
onClick={() => navigate(`/${pathname.split('/')[1]}/search${search}`)}
>
Modify search
</Button>
</Row>
</Col>
<Col md={10}>
<div className="wm-bg wm-content">
Expand Down Expand Up @@ -292,7 +321,6 @@ export default function Affiliations() {
allOpenalexCorrections={allOpenalexCorrections}
/>
</div>

<ViewsSelector
allAffiliations={filteredAffiliations}
filteredAffiliationName={filteredAffiliationName}
Expand Down

0 comments on commit f41116d

Please sign in to comment.