Skip to content

Commit

Permalink
feat(author): display anonymous author
Browse files Browse the repository at this point in the history
  • Loading branch information
BastienTeissier committed May 6, 2021
1 parent f50a35b commit 5b78e50
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
28 changes: 14 additions & 14 deletions src/components/AuthorAndSupports/AuthorAndSupports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ const AuthorAndSupports: FunctionComponent<AuthorAndSupportsProps> = ({ cause, s
const isUserLoggedIn = Boolean(useSelector(isUserLogged));
const intl = useIntl();

if (cause.author === undefined || cause.author === null) {
return null;
}

return (
<Container>
{showAuthor === true ? (
<AuthorContainer>
<IconAndLabel
iconSrc="/images/user.svg"
label={intl.formatMessage(
{ id: 'cause.author' },
{
firstName: cause.author.first_name,
lastName:
isUserLoggedIn && cause.author.last_name !== undefined
? cause.author.last_name
: cause.author.last_name_initial,
},
)}
label={
cause.author === undefined || cause.author === null
? intl.formatMessage({ id: 'cause.anonymous-author' })
: intl.formatMessage(
{ id: 'cause.author' },
{
firstName: cause.author.first_name,
lastName:
isUserLoggedIn && cause.author.last_name !== undefined
? cause.author.last_name
: cause.author.last_name_initial,
},
)
}
/>
</AuthorContainer>
) : null}
Expand Down
10 changes: 6 additions & 4 deletions src/components/Cause/Cause.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const Cause: FunctionComponent<CauseProps> = ({ cause }: CauseProps) => {
<StyledContent>
<CoalitionsDisplay cause={cause} small />
<CauseName>{cause.name}</CauseName>
{cause.author !== undefined && cause.author !== null ? (
<Author>
<Author>
{cause.author !== undefined && cause.author !== null ? (
<FormattedMessage
id="cause.author"
values={{
Expand All @@ -71,8 +71,10 @@ const Cause: FunctionComponent<CauseProps> = ({ cause }: CauseProps) => {
: cause.author.last_name_initial,
}}
/>
</Author>
) : null}
) : (
<FormattedMessage id="cause.anonymous-author" />
)}
</Author>
<AuthorAndSupports cause={cause} />
<ButtonContainer>
{Boolean(cause.supported) || (
Expand Down
1 change: 1 addition & 0 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
},
"cause": {
"author": "Par {firstName} {lastName}",
"anonymous-author": "Auteur Anonyme",
"support": "{supportsNumber} soutien",
"supports": "{supportsNumber} soutiens",
"support-button": "Soutenir",
Expand Down

0 comments on commit 5b78e50

Please sign in to comment.