diff --git a/src/api/news.js b/src/api/news.js
index d64981c66..638c0f432 100644
--- a/src/api/news.js
+++ b/src/api/news.js
@@ -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,
@@ -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,
})
@@ -61,4 +57,5 @@ export const createNewsQuery = news =>
published: true,
zone: news.zoneId,
enriched: true,
+ committee: news.committeeUuid,
})
diff --git a/src/components/News/CreateEditModal.jsx b/src/components/News/CreateEditModal.jsx
index f7f45c88e..9051c6926 100644
--- a/src/components/News/CreateEditModal.jsx
+++ b/src/components/News/CreateEditModal.jsx
@@ -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'),
@@ -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)
)
},
})
diff --git a/src/components/News/NewsList.jsx b/src/components/News/NewsList.jsx
index 477752688..236762ad4 100644
--- a/src/components/News/NewsList.jsx
+++ b/src/components/News/NewsList.jsx
@@ -18,7 +18,12 @@ const NewsList = ({ data, toggleNewsStatus, toggleNewsPinned, handleEdit, handle
header={
<>
-
+
>
}
actionsProps={{ sx: { pt: 3 } }}
diff --git a/src/domain/news.js b/src/domain/news.js
index ae2a8123a..c64e1e0ae 100644
--- a/src/domain/news.js
+++ b/src/domain/news.js
@@ -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
@@ -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(
@@ -28,7 +43,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -44,7 +60,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -60,7 +77,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -76,7 +94,8 @@ export default class News {
this.withNotification,
this.status,
this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -92,7 +111,8 @@ export default class News {
newWithNotification,
this.status,
this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -108,7 +128,8 @@ export default class News {
this.withNotification,
newStatus,
this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -124,7 +145,8 @@ export default class News {
this.withNotification,
this.status,
newPinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -140,7 +162,8 @@ export default class News {
this.withNotification,
!this.status,
this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -156,7 +179,8 @@ export default class News {
this.withNotification,
this.status,
!this.pinned,
- this.zoneId
+ this.zoneId,
+ this.committeeUuid
)
}
@@ -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
)
}
}
@@ -189,4 +231,5 @@ News.propTypes = PropTypes.shape({
status: PropTypes.bool.isRequired,
pinned: PropTypes.bool.isRequired,
zoneId: PropTypes.string,
+ committeeUuid: PropTypes.string,
})