fixed error without contributors

This commit is contained in:
Sebastian Sdorra
2020-06-11 08:08:47 +02:00
parent ce2212d41f
commit 9d6621ca51
3 changed files with 11 additions and 3 deletions

View File

@@ -128,6 +128,8 @@ const Contributors: FC<PersonsProps> = ({ persons, label, displayTextOnly }) =>
} }
}; };
const emptyListOfContributors: Person[] = [];
const ChangesetAuthor: FC<Props> = ({ changeset }) => { const ChangesetAuthor: FC<Props> = ({ changeset }) => {
const binder = useBinder(); const binder = useBinder();
@@ -140,7 +142,10 @@ const ChangesetAuthor: FC<Props> = ({ changeset }) => {
}; };
const filterContributorsByType = (type: string) => { const filterContributorsByType = (type: string) => {
if (changeset.contributors) {
return changeset.contributors.filter(p => p.type === type).map(contributor => contributor.person); return changeset.contributors.filter(p => p.type === type).map(contributor => contributor.person);
}
return emptyListOfContributors;
}; };
const authorLine = []; const authorLine = [];

View File

@@ -36,7 +36,7 @@ export type Changeset = Collection & {
date: Date; date: Date;
author: Person; author: Person;
description: string; description: string;
contributors: Contributor[]; contributors?: Contributor[];
_links: Links; _links: Links;
_embedded: { _embedded: {
tags?: Tag[]; tags?: Tag[];

View File

@@ -66,7 +66,10 @@ const BottomMarginLevel = styled(Level)`
`; `;
const countContributors = (changeset: Changeset) => { const countContributors = (changeset: Changeset) => {
if (changeset.contributors) {
return changeset.contributors.length + 1; return changeset.contributors.length + 1;
}
return 1;
}; };
const ContributorLine = styled.div` const ContributorLine = styled.div`