<commit_before>import * as React from "react"
import * as Relay from "react-relay"
import TextLink from "../text_link"

export class ArtworkContact extends React.Component<RelayProps, null> {

  contactLine() {
    const artwork = this.props.artwork
    if (artwork.sale && artwork.sale.is_auction) {
      return this.auctionLine()
    } else if (artwork.is_inquireable) {
      return this.contactPartnerLine()
    }
  }

  auctionLine() {
    const artwork = this.props.artwork
    if (artwork.sale.is_live_open) {
      return (
        <TextLink href={ artwork.href } underline={ true }>Enter Live Auction</TextLink>
      )
    } else if (artwork.sale.is_open) {
      const sa = artwork.sale_artwork
      const bids = sa.counts.bidder_positions
      if (bids > 0) {
        const s = bids > 1 ? "s" : ""
        return (
          <span>
            { sa.highest_bid.display } ({ bids } bid{ s })
          </span>
        )
      } else {
        return (
          <span>
            { sa.opening_bid.display }
          </span>
        )
      }
    } else if (artwork.sale.is_closed) {
      return (<span>Auction closed</span>)
    } else {
      return (<span/>)
    }
  }

  contactPartnerLine() {
    return (
      <TextLink href={ this.props.artwork.href } underline={ true }>
        Contact { this.props.artwork.partner.type.toLowerCase() }
      </TextLink>
    )
  }

  render() {
    return (
      <div>
        { this.contactLine() }
      </div>
    )
  }
}

export default Relay.createContainer(ArtworkContact, {
  fragments: {
    artwork: () => Relay.QL`
      fragment on Artwork {
        _id
        href
        is_inquireable
        sale {
          is_auction
          is_live_open
          is_open
          is_closed
        }
        partner(shallow: true) {
          type
        }
        sale_artwork {
          highest_bid {
            display
          }
          opening_bid {
            display
          }
          counts {<commit_msg>Refactor the ArtworkContact component<commit_after>import * as React from "react"
import * as Relay from "react-relay"
import TextLink from "../text_link"

export class ArtworkContact extends React.Component<RelayProps, null> {

  contactLine() {
    const { artwork } = this.props
    if (artwork.sale && artwork.sale.is_auction) {
      return this.auctionLine()
    } else if (artwork.is_inquireable) {
      return this.contactPartnerLine()
    }
  }

  auctionLine() {
    const { artwork } = this.props
    if (artwork.sale.is_live_open) {
      return <TextLink href={ artwork.href } underline={ true }>Enter Live Auction</TextLink>
    } else if (artwork.sale.is_open) {
      const sa = artwork.sale_artwork
      const bids = sa.counts.bidder_positions
      if (bids > 0) {
        const s = bids > 1 ? "s" : ""
        return <span>{ sa.highest_bid.display } ({ bids } bid{ s })</span>
      } else {
        return <span>{ sa.opening_bid.display }</span>
      }
    } else if (artwork.sale.is_closed) {
      return <span>Auction closed</span>
    } else {
      return <span/>
    }
  }

  contactPartnerLine() {
    return (
      <TextLink href={ this.props.artwork.href } underline={ true }>
        Contact { this.props.artwork.partner.type.toLowerCase() }
      </TextLink>
    )
  }

  render() {
    return <div>{ this.contactLine() }</div>
  }
}

export default Relay.createContainer(ArtworkContact, {
  fragments: {
    artwork: () => Relay.QL`
      fragment on Artwork {
        _id
        href
        is_inquireable
        sale {
          is_auction
          is_live_open
          is_open
          is_closed
        }
        partner(shallow: true) {
          type
        }
        sale_artwork {
          highest_bid {
            display
          }
          opening_bid {
            display
          }
          counts {
{'fraction_non_alphanumeric': 0.11209133367929423, 'fraction_numerical': 0.0010378827192527244, 'mean_word_length': 1.813868613138686, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2472463', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1210, 'n_words': 259}