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 4aa58d8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/components/Layout/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import MentionsLegales from './MentionsLegales'
import { styled } from '@mui/system'
import { Button, Grid, Stack } from '@mui/material'
import { APP_VERSION } from '~/shared/environments'
import Iconify from '~/mui/iconify'
import { useSelector } from 'react-redux'
import { getFeaturebaseToken } from '~/redux/user/selectors.js'

Expand Down
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
10 changes: 7 additions & 3 deletions src/components/News/ReadModal.jsx
Original file line number Diff line number Diff line change
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 4aa58d8

Please sign in to comment.