import React from 'react'
import { ListItemContainer } from './ListItemContainer'
import { ListItemInfoContainer } from './ListItemInfoContainer'
import { ListItemTitle } from './ListItemTitle'
import { Product } from '../types/Product'
import { ListProductImage } from './ListProductImage'
import { ListItemSupplName } from './ListItemSupplName'
import { ListItemInfoDate } from './ListItemInfoDate'

export interface ProductListItem {
  index?: number
  product: Product
  onPress?: () => void
}

export const ProductListItem: React.FC<ProductListItem> = ({
  product,
  onPress,
  index,
}) => {
  return (
    <ListItemContainer onPress={onPress}>
      <ListProductImage product={product} isExplicit={false} rank={index} />
      <ListItemInfoContainer>
        <ListItemTitle title={product.name} />
        {product.digitalTitleSuppl != null ? (
          <ListItemSupplName title={product.digitalTitleSuppl} />
        ) : null}
        {product.releaseDate != null ? (
          <ListItemInfoDate releaseDate={product.releaseDate} />
        ) : null}
      </ListItemInfoContainer>
    </ListItemContainer>
  )
}
