<commit_before>import * as React from "react"
import * as Relay from "react-relay"

import { MetadataText, SmallHeadline } from "../Components/Inbox/Typography"

import {
  FlatList,
  ImageURISource,
  KeyboardAvoidingView,
  Text,
  TextInput,
  TouchableOpacity,
  ViewProperties,
} from "react-native"

import styled from "styled-components/native"
import colors from "../../data/colors"
import fonts from "../../data/fonts"

import BottomAlignedButton from "../Components/Consignments/Components/BottomAlignedButton"

import ArtworkPreview from "../Components/Inbox/Conversations/ArtworkPreview"
import ARSwitchBoard from "../NativeModules/SwitchBoard"
import { gravityURL } from "../relay/config"

const Container = styled.View`
  flex: 1
  flex-direction: column
`
const Header = styled.View`
  alignSelf: stretch
  margin-top: 10
  flex-direction: column
  margin-bottom: 30
`
// This is really rubbish, but I basically have to create an equally sized element
// on the top right, to get the title in the middle
const PlaceholderView = styled(SmallHeadline)`
  padding-right: 20
  color: white
`
const TitleView = styled.View`
  align-self: center
  align-items: center
  margin-top: 6
`
const HeaderTextContainer = styled.View`
  flex-direction: row
  justify-content: space-between
`
const CancelButton = styled.TouchableOpacity`
  padding-left: 20
`
const Content = styled.View`
  margin-left: 20
  margin-right: 20
`
const InquiryTextInput = styled.TextInput`
  font-size: 16
  margin-top:20
  font-family: ${fonts["garamond-regular"]}
`
const ResponseRate = styled(SmallHeadline)`
  color: ${colors["yellow-bold"]}
  marginTop: 5
`
const ResponseIndicator = styled.View`
  width: 8
  height: 8
  border-radius: 4
  margin-top: 5
  margin-right: 5
  background-color: ${colors["yellow-bold"]}
`
const ResponseRateLine = styled.View`
  flex: 1
  flex-direction: row
  align-items: center
  min-height: 12
  margin-top: 5
`

export class Inquiry extends React.Component<RelayProps, any> {
  constructor(props) {
    super(props)

    this.state = {
      text: this.props.inquiry.partner.contact_message,
    }
  }

  dismissModal() {
    ARSwitchBoard.dismissModalViewController(this)
  }

  sendInquiry() {
    fetch(gravityURL + "/api/v1/me/artwork_inquiry_request", {
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        artwork: this.props.inquiry.id,
        message: this.state.text,
      }),
    })
    this.dismissModal()
  }

  render() {
    const message = this.state.text
    const partnerResponseRate = "2 DAY RESPONSE TIME"
    const artwork = this.props.inquiry
    console.log(this.props)
    const partnerName = this.props.inquiry.partner.name

    const doneButtonStyles = {
      backgroundColor: colors["purple-regular"],
      marginBottom: 0,
      paddingTop: 12,
      height: 44,
    }

    return (
      <Container>
        <BottomAlignedButton onPress={this.sendInquiry.bind(this)} bodyStyle={doneButtonStyles} buttonText="SEND"><commit_msg>[MSG] Display 'sending...' on button whilst inquiry is attempting to send<commit_after>import * as React from "react"
import * as Relay from "react-relay"

import { MetadataText, SmallHeadline } from "../Components/Inbox/Typography"

import {
  FlatList,
  ImageURISource,
  KeyboardAvoidingView,
  NativeModules,
  Text,
  TextInput,
  TouchableOpacity,
  ViewProperties,
} from "react-native"

import styled from "styled-components/native"
import colors from "../../data/colors"
import fonts from "../../data/fonts"

import BottomAlignedButton from "../Components/Consignments/Components/BottomAlignedButton"

import ArtworkPreview from "../Components/Inbox/Conversations/ArtworkPreview"
import ARSwitchBoard from "../NativeModules/SwitchBoard"
import { gravityURL } from "../relay/config"
import { NetworkError } from "../system/errors"

const Container = styled.View`
  flex: 1
  flex-direction: column
`
const Header = styled.View`
  alignSelf: stretch
  margin-top: 10
  flex-direction: column
  margin-bottom: 30
`
// This is really rubbish, but I basically have to create an equally sized element
// on the top right, to get the title in the middle
const PlaceholderView = styled(SmallHeadline)`
  padding-right: 20
  color: white
`
const TitleView = styled.View`
  align-self: center
  align-items: center
  margin-top: 6
`
const HeaderTextContainer = styled.View`
  flex-direction: row
  justify-content: space-between
`
const CancelButton = styled.TouchableOpacity`
  padding-left: 20
`
const Content = styled.View`
  margin-left: 20
  margin-right: 20
`
const InquiryTextInput = styled.TextInput`
  font-size: 16
  margin-top:20
  font-family: ${fonts["garamond-regular"]}
`
const ResponseRate = styled(SmallHeadline)`
  color: ${colors["yellow-bold"]}
  marginTop: 5
`
const ResponseIndicator = styled.View`
  width: 8
  height: 8
  border-radius: 4
  margin-top: 5
  margin-right: 5
  background-color: ${colors["yellow-bold"]}
`
const ResponseRateLine = styled.View`
  flex: 1
  flex-direction: row
  align-items: center
  min-height: 12
  margin-top: 5
`

export class Inquiry extends React.Component<RelayProps, any> {
  constructor(props) {
    super(props)

    this.state = {
      text: this.props.inquiry.partner.contact_message,
      sending: false,
    }
  }

  dismissModal() {
    ARSwitchBoard.dismissModalViewController(this)
  }

  sendInquiry() {
    this.setState(previousState => {
      return { sending: true }
    })
    const { Emission } = NativeModules
    fetch(gravityURL + "/api/v1/me/artwork_inquiry_request", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-ACCESS-TOKEN": Emission.authenticationToken,
      },
      body: JSON.stringify({
        artwork: this.props.inquiry.id,
        message: this.state.text,
      }),
    })
      .then(response => {
        console.log(response)
        if (response.status >= 200 && response.status < 300) {
          this.dismissModal()
        } else {
          this.setState(previousState => {
            return { sending: false }
          })
          const error = new NetworkError(response)
          console.log(error.message)
          error.response = response
          throw error
        }
      })
      .catch(error => {
        this.setState(previousState => {
          return { sending: false }
        })
        console.log(error.message)
        console.log(error)
        throw error
      })
  }

  render() {
    const message = this.state.text
    const partnerResponseRate = "2 DAY RESPONSE TIME"
    const artwork = this.props.inquiry
    const partnerName = this.props.inquiry.partner.name
    const buttonText = this.state.sending ? "SENDING..." : "SEND"

    const doneButtonStyles = {
      backgroundColor: colors["purple-regular"],
      marginBottom: 0,
      paddingTop: 12,
      height: 44,
    }

    return (
      <Container>
        <BottomAlignedButton onPress={this.sendInquiry.bind(this)} bodyStyle={doneButtonStyles} buttonText={buttonText}>
{'fraction_non_alphanumeric': 0.11510892480674631, 'fraction_numerical': 0.0106816584680253, 'mean_word_length': 3.1932822628167354, 'pattern_counts': {'":': 3, '<': 10, '<?xml version=': 0, '>': 15, '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': '2989508', 'n_tokens_mistral': 2267, 'n_tokens_neox': 2179, 'n_words': 531}