Skip to content

Commit

Permalink
rework condition
Browse files Browse the repository at this point in the history
  • Loading branch information
finlay-jisc committed Dec 19, 2024
1 parent 781c4fb commit bcdc619
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions ui/src/pages/authors/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,30 @@ const Author: Types.NextPage<Props> = (props): React.ReactElement => {
const publicationVersions: Interfaces.PublicationVersion[] = useMemo(
() =>
response?.data
? response.data
// Explicitly specify our expectation about the first version being latest live for typescript.
.filter((publication) => publication.versions[0].isLatestLiveVersion)
.map((publication) => {
const version = publication.versions[0];
version.user = {
id: props.user.id,
createdAt: props.user.createdAt,
email: props.user.email || '',
firstName: props.user.firstName,
lastName: props.user.lastName,
orcid: props.user.orcid,
updatedAt: props.user.updatedAt,
role: props.user.role
};

version.publication = {
id: publication.id,
type: publication.type,
doi: publication.doi,
url_slug: publication.url_slug,
flagCount: publication.flagCount,
peerReviewCount: publication.peerReviewCount
};
return version;
})
: [],
?.filter((publication) => publication.versions[0].isLatestLiveVersion)
.map((publication) => {
const version = publication.versions[0];
version.user = {
id: props.user.id,
createdAt: props.user.createdAt,
email: props.user.email || '',
firstName: props.user.firstName,
lastName: props.user.lastName,
orcid: props.user.orcid,
updatedAt: props.user.updatedAt,
role: props.user.role
};

version.publication = {
id: publication.id,
type: publication.type,
doi: publication.doi,
url_slug: publication.url_slug,
flagCount: publication.flagCount,
peerReviewCount: publication.peerReviewCount
};
return version;
}) || [],
[response, props.user]
);

Expand Down

0 comments on commit bcdc619

Please sign in to comment.