Skip to content

Commit 8e77f34

Browse files
committed
2927: Started work on upgrading poster component to work with v2 api
1 parent 4f1acc0 commit 8e77f34

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function PosterSelector({
7979
"singleSelectedOccurrence"
8080
);
8181

82+
console.log(occurrenceId, "occurrenceId");
83+
8284
if (eventId !== null) {
8385
fetch(`${url}?path=${eventId}`, {
8486
headers,
@@ -93,12 +95,12 @@ function PosterSelector({
9395
}
9496

9597
if (occurrenceId !== null) {
96-
fetch(`${url}?path=${occurrenceId}`, {
98+
fetch(`${url}?path=/occurrences/${occurrenceId}`, {
9799
headers,
98100
})
99101
.then((response) => response.json())
100102
.then((data) => {
101-
setSingleSelectedOccurrence(data);
103+
setSingleSelectedOccurrence(data["hydra:member"][0]);
102104
})
103105
.catch(() => {
104106
// TODO: Display error.
@@ -121,7 +123,7 @@ function PosterSelector({
121123
target: {
122124
id: "singleSelectedOccurrence",
123125
value: singleSelectedOccurrence
124-
? singleSelectedOccurrence["@id"]
126+
? singleSelectedOccurrence.entityId
125127
: null,
126128
},
127129
});
@@ -235,7 +237,7 @@ function PosterSelector({
235237

236238
switch (singleSearchType) {
237239
case "title":
238-
query = `${query}&name=${singleSearch}`;
240+
query = `${query}&title=${singleSearch}`;
239241
break;
240242
case "url":
241243
query = `${query}&url=${singleSearch}`;
@@ -303,7 +305,7 @@ function PosterSelector({
303305
let query = `?type=${type}&display=options`;
304306

305307
if (inputValue) {
306-
query = `${query}&name=${inputValue}`;
308+
query = `${query}&title=${inputValue}`;
307309
}
308310

309311
// TODO: Get this endpoint in a different way.
@@ -391,7 +393,7 @@ function PosterSelector({
391393
{singleSelectedEvent && (
392394
<div>
393395
<strong>Valgt begivenhed:</strong>{" "}
394-
{singleSelectedEvent.name} (
396+
{singleSelectedEvent.title} (
395397
{singleSelectedEvent?.organizer?.name})
396398
</div>
397399
)}
@@ -400,7 +402,7 @@ function PosterSelector({
400402
<strong>
401403
{t("poster-selector.chosen-occurrence")}:
402404
</strong>{" "}
403-
{formatDate(singleSelectedOccurrence.startDate)} -
405+
{formatDate(singleSelectedOccurrence.start)} -
404406
{singleSelectedOccurrence.ticketPriceRange}
405407
</div>
406408
)}
@@ -596,23 +598,23 @@ function PosterSelector({
596598
onClick={() => handleSelectEvent(searchEvent)}
597599
>
598600
<td>
599-
{searchEvent?.images?.small && (
601+
{searchEvent?.imageUrls?.small && (
600602
<img
601-
src={searchEvent?.images?.small}
602-
alt={searchEvent?.name}
603+
src={searchEvent?.imageUrls?.small}
604+
alt={searchEvent?.title}
603605
style={{ maxWidth: "80px" }}
604606
/>
605607
)}
606608
</td>
607609
<td>
608-
<strong>{searchEvent.name}</strong>
610+
<strong>{searchEvent.title}</strong>
609611
<br />
610612
{searchEvent.organizer.name}
611613
</td>
612614
<td>
613615
{searchEvent?.occurrences?.length > 0 &&
614616
formatDate(
615-
searchEvent?.occurrences[0]?.startDate
617+
searchEvent?.occurrences[0]?.start
616618
)}
617619
{searchEvent?.occurrences?.length > 1 && (
618620
<span>, ...</span>
@@ -658,7 +660,7 @@ function PosterSelector({
658660
{singleSelectedEvent?.occurrences?.map(
659661
(occurrence) => (
660662
<tr>
661-
<td>{occurrence.startDate}</td>
663+
<td>{occurrence.start}</td>
662664
<td>{occurrence.ticketPriceRange}</td>
663665
<td>
664666
<Button
@@ -844,7 +846,7 @@ function PosterSelector({
844846
<tr>
845847
<td>
846848
<img
847-
src={event?.images?.small}
849+
src={event?.imageUrls?.small}
848850
alt={event.name}
849851
style={{ maxWidth: "80px" }}
850852
/>
@@ -862,10 +864,10 @@ function PosterSelector({
862864
{firstOccurrence && (
863865
<>
864866
{`${formatDate(
865-
firstOccurrence.startDate,
867+
firstOccurrence.start,
866868
"L"
867869
)} - ${formatDate(
868-
firstOccurrence.endDate,
870+
firstOccurrence.end,
869871
"L"
870872
)}`}
871873
</>

0 commit comments

Comments
 (0)