Skip to content

Commit

Permalink
Allow RCL to send Committee notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Dec 19, 2024
1 parent 31005a6 commit dac8451
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 20 deletions.
7 changes: 2 additions & 5 deletions src/api/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getNewsQuery = async ({ pageParam: page = 1 }) => {
n.text,
n.external_link,
n.link_label,
n.creator,
n.author,
parseDate(n.created_at),
n.notification,
n.published,
Expand All @@ -31,17 +31,13 @@ export const getNewsQuery = async ({ pageParam: page = 1 }) => {

export const updateNewsQuery = news =>
apiClient.put(`api/v3/jecoute/news/${news.id}`, {
uuid: news.id,
title: news.title,
text: news.body,
created_at: news.createdAt,
external_link: news.url,
link_label: news.urlLabel,
creator: news.creator,
notification: news.withNotification,
published: news.status,
pinned: news.pinned,
zone: news.zoneId,
enriched: true,
})

Expand All @@ -61,4 +57,5 @@ export const createNewsQuery = news =>
published: true,
zone: news.zoneId,
enriched: true,
committee: news.committeeUuid,
})
4 changes: 2 additions & 2 deletions src/components/News/CreateEditModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { SubTitle, Title } from './styles'
import Button from '~/ui/Button'
import Dialog from '~/ui/Dialog'
import { EDITOR_IMAGE_UPLOAD_URL } from './constants'
import scopes from '~/shared/scopes'

const newsSchema = Yup.object({
title: Yup.string().min(1, 'Minimum 1 caractère').max(120, 'Maximum 120 caractères').required('Titre obligatoire'),
Expand Down Expand Up @@ -95,7 +94,8 @@ const CreateEditModal = ({ open, news, onCloseResolve, onSubmitResolve }) => {
.withUrlLabel(values.urlLabel)
.withWithNotification(values.withNotification)
.withStatus(values.status)
.withZoneId(currentScope.code === scopes.national ? null : currentScope.zones[0].uuid)
.withZoneId(currentScope.zones.length ? currentScope.zones[0].uuid : null)
.withCommitteeUuid(currentScope.getCommittees()[0]?.uuid ?? null)
)
},
})
Expand Down
7 changes: 6 additions & 1 deletion src/components/News/NewsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ const NewsList = ({ data, toggleNewsStatus, toggleNewsPinned, handleEdit, handle
header={
<>
<Header {...n} />
<Title subject={n.title} author={n.creator} sx={{ pt: 1 }} dateTime={n.createdAt} />
<Title
subject={n.title}
author={`${n.creator.first_name} ${n.creator.last_name}`}
sx={{ pt: 1 }}
dateTime={n.createdAt}
/>
</>
}
actionsProps={{ sx: { pt: 3 } }}
Expand Down
67 changes: 55 additions & 12 deletions src/domain/news.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import PropTypes from 'prop-types'

export default class News {
constructor(id, title, body, url, urlLabel, creator, createdAt, withNotification, status, pinned, zoneId) {
constructor(
id,
title,
body,
url,
urlLabel,
creator,
createdAt,
withNotification,
status,
pinned,
zoneId,
committeeUuid
) {
this.id = id
this.title = title
this.body = body
Expand All @@ -12,9 +26,10 @@ export default class News {
this.status = status
this.pinned = pinned
this.zoneId = zoneId
this.committeeUuid = committeeUuid
}

static NULL = new News(null, '', '', '', '', '', new Date(), false, false, false, '')
static NULL = new News(null, '', '', '', '', '', new Date(), false, false, false, '', null)

withTitle(newTitle) {
return new News(
Expand All @@ -28,7 +43,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -44,7 +60,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -60,7 +77,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -76,7 +94,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -92,7 +111,8 @@ export default class News {
newWithNotification,
this.status,
this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -108,7 +128,8 @@ export default class News {
this.withNotification,
newStatus,
this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -124,7 +145,8 @@ export default class News {
this.withNotification,
this.status,
newPinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -140,7 +162,8 @@ export default class News {
this.withNotification,
!this.status,
this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -156,7 +179,8 @@ export default class News {
this.withNotification,
this.status,
!this.pinned,
this.zoneId
this.zoneId,
this.committeeUuid
)
}

Expand All @@ -172,7 +196,25 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
newZoneId
newZoneId,
this.committeeUuid
)
}

withCommitteeUuid(committeeUuid) {
return new News(
this.id,
this.title,
this.body,
this.url,
this.urlLabel,
this.creator,
this.createdAt,
this.withNotification,
this.status,
this.pinned,
this.zoneId,
committeeUuid
)
}
}
Expand All @@ -189,4 +231,5 @@ News.propTypes = PropTypes.shape({
status: PropTypes.bool.isRequired,
pinned: PropTypes.bool.isRequired,
zoneId: PropTypes.string,
committeeUuid: PropTypes.string,
})

0 comments on commit dac8451

Please sign in to comment.