diff --git a/src/components/slide/content/poster/poster-single-events.jsx b/src/components/slide/content/poster/poster-single-events.jsx new file mode 100644 index 00000000..c62685f8 --- /dev/null +++ b/src/components/slide/content/poster/poster-single-events.jsx @@ -0,0 +1,80 @@ +import { Button } from "react-bootstrap"; +import { React } from "react"; +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatDate } from "./poster-helper"; + +/** + * @param {object} props The props. + * @param {Array} props.events The events to present. + * @param {Function} props.handleSelectEvent Handle select event. + * @returns {React.JSX.Element} The events list component. + */ +function PosterSingleEvents({ events, handleSelectEvent }) { + const { t } = useTranslation("common", { keyPrefix: "poster-selector-v2" }); + + return ( + + + + + + + + + + {events?.map( + ({ entityId, title, imageUrls, organizer, occurrences }) => ( + + + + + + + ) + )} + {events?.length === 0 && ( + + + + )} + +
{t("table-image")}{t("table-event")}{t("table-date")} +
+ {imageUrls?.small && ( + {t("search-result-image")} + )} + + {title} +
+ {organizer?.name} +
+ {occurrences?.length > 0 && formatDate(occurrences[0]?.start)} + {occurrences?.length > 1 && , ...} + + +
{t("no-results")}
+ ); +} + +PosterSingleEvents.propTypes = { + events: PropTypes.arrayOf(PropTypes.shape({})).isRequired, + handleSelectEvent: PropTypes.func.isRequired, +}; + +export default PosterSingleEvents; diff --git a/src/components/slide/content/poster/poster-single-occurences.jsx b/src/components/slide/content/poster/poster-single-occurences.jsx new file mode 100644 index 00000000..d3b49891 --- /dev/null +++ b/src/components/slide/content/poster/poster-single-occurences.jsx @@ -0,0 +1,56 @@ +import { Button } from "react-bootstrap"; +import { React } from "react"; +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatDate } from "./poster-helper"; + +/** + * @param {object} props The props. + * @param {Array} props.occurrences The occurrences. + * @param {Function} props.handleSelectOccurrence The select callback. + * @returns {React.JSX.Element} The occurrences list component. + */ +function PosterSingleOccurrences({ occurrences, handleSelectOccurrence }) { + const { t } = useTranslation("common", { keyPrefix: "poster-selector-v2" }); + + return ( + <> +
{t("choose-an-occurrence")}
+ + + + + + + + + {occurrences.map(({ entityId, start, ticketPriceRange }) => ( + + + + + + ))} + +
{t("table-date")}{t("table-price")} +
{formatDate(start)}{ticketPriceRange} + +
+ + ); +} + +PosterSingleOccurrences.propTypes = { + occurrences: PropTypes.arrayOf( + PropTypes.shape({ + entityId: PropTypes.number.isRequired, + start: PropTypes.string.isRequired, + ticketPriceRange: PropTypes.string.isRequired, + }) + ).isRequired, + handleSelectOccurrence: PropTypes.func.isRequired, +}; + +export default PosterSingleOccurrences; diff --git a/src/components/slide/content/poster/poster-single.jsx b/src/components/slide/content/poster/poster-single.jsx index b341fb6e..b637f257 100644 --- a/src/components/slide/content/poster/poster-single.jsx +++ b/src/components/slide/content/poster/poster-single.jsx @@ -6,6 +6,8 @@ import Col from "react-bootstrap/Col"; import { formatDate, getHeaders } from "./poster-helper"; import PosterSingleOverride from "./poster-single-override"; import PosterSingleSearch from "./poster-single-search"; +import PosterSingleEvents from "./poster-single-events.jsx"; +import PosterSingleOccurrences from "./poster-single-occurences.jsx"; /** * @param {object} props Props. @@ -203,69 +205,10 @@ function PosterSingle({ configurationChange, feedSource, configuration }) { {singleSearchEvents && ( - - - - - - - - - - {singleSearchEvents?.map( - ({ - entityId, - title, - imageUrls, - organizer, - occurrences, - }) => ( - - - - - - - ) - )} - {singleSearchEvents?.length === 0 && ( - - - - )} - -
{t("table-image")}{t("table-event")}{t("table-date")} -
- {imageUrls?.small && ( - {t("search-result-image")} - )} - - {title} -
- {organizer?.name} -
- {occurrences?.length > 0 && - formatDate(occurrences[0]?.start)} - {occurrences?.length > 1 && , ...} - - -
{t("no-results")}
+
)} @@ -273,31 +216,10 @@ function PosterSingle({ configurationChange, feedSource, configuration }) { {singleSelectedEvent !== null && singleSelectedOccurrence === null && ( -
{t("choose-an-occurrence")}
- - - - - - - - - {singleSelectedEvent.occurrences.map( - ({ entityId, start, ticketPriceRange }) => ( - - - - - - ) - )} - -
{t("table-date")}{t("table-price")} -
{formatDate(start)}{ticketPriceRange} - -
+
)}