Skip to content

Commit

Permalink
[News] fix empty author
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Dec 30, 2024
1 parent ec40b77 commit 0c94c64
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/News/NewsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const NewsList = ({ data, toggleNewsStatus, toggleNewsPinned, handleEdit, handle
<Header {...n} />
<Title
subject={n.title}
author={`${n.creator.first_name} ${n.creator.last_name}`}
author={n.creator ? `${n.creator.first_name} ${n.creator.last_name}` : null}
sx={{ pt: 1 }}
dateTime={n.createdAt}
/>
Expand Down
12 changes: 8 additions & 4 deletions src/components/News/ReadModal.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react'
import PropTypes from 'prop-types'
import { Grid, Icon as MuiIcon, Typography } from '@mui/material'
import { Box, Grid, Typography } from '@mui/material'
import { styled } from '@mui/system'
import NotificationsActiveRoundedIcon from '@mui/icons-material/NotificationsActiveRounded'
import NotificationsOffRoundedIcon from '@mui/icons-material/NotificationsOffRounded'
Expand Down Expand Up @@ -128,9 +128,13 @@ const ReadModal = ({ open, news, handleEdit, onCloseResolve }) => {
</Grid>
<Title title={news?.title}>{news?.title}</Title>
<UserTimeContainer>
<PersonIcon sx={{ mr: 0.5, color: 'gray600', fontSize: '12px' }} />
<Author>{`${news?.creator?.first_name} ${news?.creator?.last_name}`}</Author>
<AccessTimeIcon sx={{ mr: 0.5, ml: 2, color: 'gray600', fontSize: '12px' }} />
{news?.creator && (
<>
<PersonIcon sx={{ mr: 0.5, color: 'gray600', fontSize: '12px' }} />
<Author>{`${news?.creator?.first_name} ${news?.creator?.last_name}`}</Author>
</>
)}
<AccessTimeIcon sx={{ mr: 0.5, color: 'gray600', fontSize: '12px' }} />
<DateItem>
{news?.createdAt && `Le ${formatDate(news.createdAt, 'dd/MM/yyyy')} à ${formatDate(news.createdAt, 'HH:mm')}`}
</DateItem>
Expand Down
16 changes: 9 additions & 7 deletions src/ui/Card/Title/Title.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ export const Title = ({ subject, author, dateTime, lines = 1, ...props }) => (
<TruncatedText variant="subtitle1" sx={{ color: 'gray900', height: '45px', mb: 0.5 }} lines={lines} title={subject}>
{subject}
</TruncatedText>
<HorizontalContainer>
<Person sx={{ mr: 0.5, color: 'gray600', fontSize: '12px' }} />
<Typography variant="subtitle2" sx={{ color: 'gray600' }}>
{author}
</Typography>
</HorizontalContainer>
{author && (
<HorizontalContainer>
<Person sx={{ mr: 0.5, color: 'gray600', fontSize: '12px' }} />
<Typography variant="subtitle2" sx={{ color: 'gray600' }}>
{author}
</Typography>
</HorizontalContainer>
)}
{dateTime && (
<HorizontalContainer>
<AccessTime sx={{ mr: 0.5, color: 'gray600', fontSize: '12px' }} />
Expand All @@ -31,6 +33,6 @@ export const Title = ({ subject, author, dateTime, lines = 1, ...props }) => (
Title.propTypes = {
subject: PropTypes.string.isRequired,
lines: PropTypes.number,
author: PropTypes.string.isRequired,
author: PropTypes.string,
dateTime: PropTypes.object,
}

0 comments on commit 0c94c64

Please sign in to comment.