Skip to content

Commit 58f6e72

Browse files
committed
2927: Use options endpoint
1 parent 46c3cfa commit 58f6e72

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

src/components/slide/content/poster/poster-helper.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ const loadDropdownOptions = (url, headers, inputValue, callback, type) => {
4242
const loadDropdownOptionsPromise = (url, headers, inputValue, type) => {
4343
return new Promise((resolve, reject) => {
4444
const params = {
45-
type,
46-
display: "options",
45+
entityType: type,
4746
};
4847

4948
if (inputValue) {
50-
params.name = inputValue;
49+
params.search = inputValue;
5150
}
5251

5352
const query = new URLSearchParams(params);

src/components/slide/content/poster/poster-selector-v2.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function PosterSelectorV2({
8989
PosterSelectorV2.propTypes = {
9090
getValueFromConfiguration: PropTypes.func.isRequired,
9191
configurationChange: PropTypes.func.isRequired,
92+
configuration: PropTypes.shape({}),
9293
feedSource: PropTypes.shape({
9394
admin: PropTypes.arrayOf(
9495
PropTypes.shape({

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ function PosterSingle({
235235
{singleSelectedOccurrence && (
236236
<div>
237237
<strong>{t("chosen-occurrence")}:</strong>{" "}
238-
{formatDate(singleSelectedOccurrence.start)} -
238+
{formatDate(singleSelectedOccurrence.startDate)}
239+
{" - "}
239240
{singleSelectedOccurrence.ticketPriceRange}
240241
</div>
241242
)}

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import {React, useEffect, useRef, useState} from "react";
1+
import { React, useEffect, useRef, useState } from "react";
22
import PropTypes from "prop-types";
33
import { useTranslation } from "react-i18next";
44
import { Row, Spinner } from "react-bootstrap";
55
import AsyncSelect from "react-select/async";
66
import Col from "react-bootstrap/Col";
7-
import {formatDate, getHeaders, loadDropdownOptions, loadDropdownOptionsPromise} from "./poster-helper";
7+
import {
8+
formatDate,
9+
getHeaders,
10+
loadDropdownOptionsPromise,
11+
} from "./poster-helper";
812

913
/**
1014
* @param {object} props Props.
@@ -38,7 +42,7 @@ function PosterSubscription({
3842

3943
const [loadingResults, setLoadingResults] = useState(false);
4044

41-
const searchEndpoint = feedSource.admin[0].endpointSearch ?? null;
45+
const optionsEndpoint = feedSource.admin[0].endpointOption ?? null;
4246

4347
const numberOptions = Array.from(Array(10).keys());
4448

@@ -133,18 +137,36 @@ function PosterSubscription({
133137
subscriptionNumberValue,
134138
]);
135139

136-
const timeoutRef = useRef(null);
140+
const locationTimeoutRef = useRef(null);
141+
const organizationTimeoutRef = useRef(null);
142+
const tagTimeoutRef = useRef(null);
137143

138144
const debounceOptions = (inputValue, type) => {
139145
// Debounce promise.
140146
return new Promise((resolve, reject) => {
147+
let timeoutRef = null;
148+
149+
switch (type) {
150+
case "locations":
151+
timeoutRef = locationTimeoutRef;
152+
break;
153+
case "organizations":
154+
timeoutRef = organizationTimeoutRef;
155+
break;
156+
case "tags":
157+
timeoutRef = tagTimeoutRef;
158+
break;
159+
default:
160+
return;
161+
}
162+
141163
if (timeoutRef.current) {
142164
clearTimeout(timeoutRef.current);
143165
}
144166

145167
timeoutRef.current = setTimeout(() => {
146168
loadDropdownOptionsPromise(
147-
searchEndpoint,
169+
optionsEndpoint,
148170
getHeaders(),
149171
inputValue,
150172
type
@@ -214,7 +236,7 @@ function PosterSubscription({
214236
{t("filters-tag")}
215237
</label>
216238
<AsyncSelect
217-
id="subscription-search-place"
239+
id="subscription-search-tag"
218240
isClearable
219241
isSearchable
220242
defaultOptions
@@ -287,12 +309,12 @@ function PosterSubscription({
287309
/>
288310
</td>
289311
<td>
290-
<strong>{event.name}</strong>
312+
<strong>{event.title}</strong>
291313
<br />
292314
{event?.organizer?.name}
293315
</td>
294316
<td>
295-
{firstOccurrence && firstOccurrence.place?.name}
317+
{firstOccurrence && firstOccurrence?.place?.name}
296318
</td>
297319
<td>
298320
{firstOccurrence && (
@@ -324,6 +346,7 @@ PosterSubscription.propTypes = {
324346
admin: PropTypes.arrayOf(
325347
PropTypes.shape({
326348
endpointEntity: PropTypes.string,
349+
endpointOption: PropTypes.string,
327350
endpointSearch: PropTypes.string,
328351
})
329352
),

0 commit comments

Comments
 (0)