-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2927: Split poster single up into components
- Loading branch information
Showing
3 changed files
with
146 additions
and
88 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
src/components/slide/content/poster/poster-single-events.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<table className="table table-hover text-left"> | ||
<thead> | ||
<tr> | ||
<th scope="col">{t("table-image")}</th> | ||
<th scope="col">{t("table-event")}</th> | ||
<th scope="col">{t("table-date")}</th> | ||
<th scope="col" aria-label={t("table-actions")} /> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{events?.map( | ||
({ entityId, title, imageUrls, organizer, occurrences }) => ( | ||
<tr key={entityId}> | ||
<td> | ||
{imageUrls?.small && ( | ||
<img | ||
src={imageUrls?.small} | ||
alt={t("search-result-image")} | ||
style={{ maxWidth: "80px" }} | ||
/> | ||
)} | ||
</td> | ||
<td> | ||
<b>{title}</b> | ||
<br /> | ||
{organizer?.name} | ||
</td> | ||
<td> | ||
{occurrences?.length > 0 && formatDate(occurrences[0]?.start)} | ||
{occurrences?.length > 1 && <span>, ...</span>} | ||
</td> | ||
<td> | ||
<Button | ||
onClick={() => | ||
handleSelectEvent( | ||
entityId, | ||
occurrences.map( | ||
({ entityId: occurrenceEntityId }) => occurrenceEntityId | ||
) | ||
) | ||
} | ||
> | ||
{t("choose-event")} | ||
</Button> | ||
</td> | ||
</tr> | ||
) | ||
)} | ||
{events?.length === 0 && ( | ||
<tr> | ||
<td colSpan="3">{t("no-results")}</td> | ||
</tr> | ||
)} | ||
</tbody> | ||
</table> | ||
); | ||
} | ||
|
||
PosterSingleEvents.propTypes = { | ||
events: PropTypes.arrayOf(PropTypes.shape({})).isRequired, | ||
handleSelectEvent: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default PosterSingleEvents; |
56 changes: 56 additions & 0 deletions
56
src/components/slide/content/poster/poster-single-occurences.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<h5>{t("choose-an-occurrence")}</h5> | ||
<table className="table table-hover text-left"> | ||
<thead> | ||
<tr> | ||
<th scope="col">{t("table-date")}</th> | ||
<th scope="col">{t("table-price")}</th> | ||
<th scope="col" aria-label={t("table-actions")} /> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{occurrences.map(({ entityId, start, ticketPriceRange }) => ( | ||
<tr key={entityId}> | ||
<td>{formatDate(start)}</td> | ||
<td>{ticketPriceRange}</td> | ||
<td> | ||
<Button onClick={() => handleSelectOccurrence(entityId)}> | ||
{t("choose-occurrence")} | ||
</Button> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</> | ||
); | ||
} | ||
|
||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters