import React from 'react'
import { FlatList, SectionList, Text, View } from 'react-native'
import {
EnterPassword,
Loading,
LoggedIn,
PromoCode,
WaitingList,
} from '../../components'
import Button from '../../components/button/Button'
import Separator from '../../components/separator/Separator'
import TicketGroupListHeader from './components/TicketGroupListHeader'
import CartListItem from './components/TicketListItem'
import s from './styles'
import { ITicketsViewProps } from './types'
const TicketsView = ({
isGettingTickets,
tickets,
groupedTickets,
styles,
onPressGetTickets,
onPressApplyPromoCode,
promoCodeValidationMessage,
isPromoCodeValid,
onSelectTicketOption,
selectedTicket,
isBookingTickets,
texts,
isGettingEvent,
event,
isWaitingListVisible,
isGetTicketsButtonVisible,
isAccessCodeEnabled,
isUserLogged,
onPressMyOrders,
onPressLogout,
areLoadingIndicatorsEnabled,
onAddToWaitingListError,
onAddToWaitingListSuccess,
onLoadingChange,
areAlertsEnabled,
promoCodeCloseIcon,
areTicketsGroupsShown,
passwordProtectedEventData,
onPressSubmitEventPassword,
}: ITicketsViewProps) => {
const isButtonDisabled = !selectedTicket || selectedTicket.selectedOption?.value === 0
const buttonText = texts?.getTicketsButton
? texts.getTicketsButton
: isButtonDisabled
? 'Get tickets'
: `Get ${selectedTicket?.selectedOption?.value} tickets`
const title = texts?.title ? texts.title : 'GET TICKETS'
return passwordProtectedEventData?.isPasswordProtected ? (
) : (
{title}
{areTicketsGroupsShown ? (
(
)}
renderSectionHeader={(data) => (
)}
/>
) : (
`ticket.${item.id}`}
renderItem={({ item, index }) => (
)}
ItemSeparatorComponent={() => }
/>
)}
{isWaitingListVisible && event?.salesStarted && (
)}
{isGetTicketsButtonVisible && (
)}
{isUserLogged && (
)}
{(isGettingTickets || isGettingEvent) && areLoadingIndicatorsEnabled && (
)}
)
}
export default TicketsView