Skip to content

Commit 16eac74

Browse files
committed
2927: Changed subscription endpoint
1 parent a233ee8 commit 16eac74

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
55

66
## [Unreleased]
77

8+
- [#279](https://github.com/os2display/display-admin-client/pull/279)
9+
- Eventdatabase v2 feed source - Change subscription endpoint.
810
- [#271](https://github.com/os2display/display-admin-client/pull/271)
911
- Added new feed source: Eventdatabasen v2.
1012

src/components/slide/content/poster/poster-subscription.jsx

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ function PosterSubscription({
2121
}) {
2222
const { t } = useTranslation("common", { keyPrefix: "poster-selector-v2" });
2323

24-
const [subscriptionEvents, setSubscriptionEvents] = useState(null);
24+
const [subscriptionOccurrences, setSubscriptionOccurrences] = useState(null);
2525
const [loadingResults, setLoadingResults] = useState(false);
2626

2727
const [firstAdmin] = admin;
2828
const optionsEndpoint = firstAdmin.endpointOption ?? null;
29-
const searchEndpoint = firstAdmin.endpointSearch ?? null;
29+
const subscriptionEndpoint = firstAdmin.endpointSubscription ?? null;
3030

3131
const {
3232
subscriptionNumberValue = [],
@@ -45,8 +45,7 @@ function PosterSubscription({
4545

4646
const subscriptionFetch = () => {
4747
const query = new URLSearchParams({
48-
type: "events",
49-
itemsPerPage: subscriptionNumberValue,
48+
numberOfItems: subscriptionNumberValue,
5049
});
5150

5251
const places = subscriptionPlaceValue.map(({ value }) => value);
@@ -69,12 +68,12 @@ function PosterSubscription({
6968

7069
setLoadingResults(true);
7170

72-
fetch(`${searchEndpoint}?${query}`, {
71+
fetch(`${subscriptionEndpoint}?${query}`, {
7372
headers: getHeaders(),
7473
})
7574
.then((response) => response.json())
7675
.then((data) => {
77-
setSubscriptionEvents(data);
76+
setSubscriptionOccurrences(data);
7877
})
7978
.finally(() => {
8079
setLoadingResults(false);
@@ -121,23 +120,23 @@ function PosterSubscription({
121120
</tr>
122121
</thead>
123122
<tbody>
124-
{subscriptionEvents?.length > 0 &&
125-
subscriptionEvents?.map(
123+
{subscriptionOccurrences?.length > 0 &&
124+
subscriptionOccurrences?.map(
126125
({
127-
entityId,
128-
occurrences,
129-
imageUrls,
126+
eventId,
127+
imageThumbnail,
128+
image,
129+
startDate,
130+
endDate,
130131
title,
131132
organizer,
133+
place,
132134
}) => {
133-
const firstOccurrence =
134-
occurrences.length > 0 ? occurrences[0] : null;
135-
136135
return (
137-
<tr key={`event-${entityId}`}>
136+
<tr key={`event-${eventId}`}>
138137
<td>
139138
<img
140-
src={imageUrls?.small}
139+
src={imageThumbnail ?? image}
141140
alt={title}
142141
style={{ maxWidth: "80px" }}
143142
/>
@@ -147,18 +146,11 @@ function PosterSubscription({
147146
<br />
148147
{organizer?.name}
149148
</td>
149+
<td>{place?.name}</td>
150150
<td>
151-
{firstOccurrence && firstOccurrence.place?.name}
152-
</td>
153-
<td>
154-
{firstOccurrence && (
155-
<>
156-
{`${formatDate(
157-
firstOccurrence.start,
158-
"L"
159-
)} - ${formatDate(firstOccurrence.end, "L")}`}
160-
</>
161-
)}
151+
{formatDate(startDate, "L HH:mm")}
152+
{" - "}
153+
{formatDate(endDate, "L HH:mm")}
162154
</td>
163155
</tr>
164156
);
@@ -194,6 +186,7 @@ PosterSubscription.propTypes = {
194186
endpointEntity: PropTypes.string,
195187
endpointOption: PropTypes.string,
196188
endpointSearch: PropTypes.string,
189+
endpointSubscription: PropTypes.string,
197190
})
198191
),
199192
}).isRequired,

0 commit comments

Comments
 (0)