<commit_before>import { tappedMakeOffer } from "@artsy/cohesion"
import { OpenInquiryModalButtonQuery } from "__generated__/OpenInquiryModalButtonQuery.graphql"
import { navigate } from "lib/navigation/navigate"
import { defaultEnvironment } from "lib/relay/createEnvironment"
import { Button, Flex, Separator } from "palette"
import React from "react"
import { graphql, QueryRenderer } from "react-relay"
import { useTracking } from "react-tracking"
import styled from "styled-components/native"

export interface OpenInquiryModalButtonProps {
  artworkID: string
  conversationID: string | null | undefined
}

const ShadowSeparator = styled(Separator)`
  box-shadow: 0 -1px 1px rgba(50, 50, 50, 0.1);
  width: 100%;
  height: 0;
`

export const OpenInquiryModalButton: React.FC<OpenInquiryModalButtonProps> = ({ artworkID, conversationID }) => {
  const { trackEvent } = useTracking()

  return (
    <>
      <ShadowSeparator />
      <Flex p={1.5}>
        <Button
          onPress={() => {
            trackEvent(tappedMakeOffer(conversationID as string))
            navigate(`make-offer/${artworkID}`, {
              modal: true,
              passProps: { conversationID },
            })
          }}
          size="large"
          variant="primaryBlack"
          block
          width={100}
        >
          Make Offer
        </Button>
      </Flex>
    </>
  )
}

export const OpenInquiryModalButtonQueryRenderer: React.FC<{
  artworkID: string
  conversationID: string
}> = ({ artworkID, conversationID }) => {
  return (
    <QueryRenderer<OpenInquiryModalButtonQuery>
      environment={defaultEnvironment}
      query={graphql`
        query OpenInquiryModalButtonQuery($artworkID: String!) {
          artwork(id: $artworkID) {
            isOfferableFromInquiry
          }
        }
      `}
      variables={{
        artworkID,
      }}
      render={({ props, error }): null | JSX.Element => {
        if (error) {
          throw new Error(error.message)
        }

        if (props?.artwork?.isOfferableFromInquiry) {
          return <OpenInquiryModalButton artworkID={artworkID} conversationID={conversationID} />
        } else {
          return null
        }
      }}
    />
  )
}<commit_msg>fix: address cache issue for make offer button<commit_after>import { tappedMakeOffer } from "@artsy/cohesion"
import { OpenInquiryModalButtonQuery } from "__generated__/OpenInquiryModalButtonQuery.graphql"
import { navigate } from "lib/navigation/navigate"
import { defaultEnvironment } from "lib/relay/createEnvironment"
import { Button, Flex, Separator } from "palette"
import React from "react"
import { graphql, QueryRenderer } from "react-relay"
import { useTracking } from "react-tracking"
import styled from "styled-components/native"

export interface OpenInquiryModalButtonProps {
  artworkID: string
  conversationID: string | null | undefined
}

const ShadowSeparator = styled(Separator)`
  box-shadow: 0 -1px 1px rgba(50, 50, 50, 0.1);
  width: 100%;
  height: 0;
`

export const OpenInquiryModalButton: React.FC<OpenInquiryModalButtonProps> = ({ artworkID, conversationID }) => {
  const { trackEvent } = useTracking()

  return (
    <>
      <ShadowSeparator />
      <Flex p={1.5}>
        <Button
          onPress={() => {
            trackEvent(tappedMakeOffer(conversationID as string))
            navigate(`make-offer/${artworkID}`, {
              modal: true,
              passProps: { conversationID },
            })
          }}
          size="large"
          variant="primaryBlack"
          block
          width={100}
        >
          Make Offer
        </Button>
      </Flex>
    </>
  )
}

export const OpenInquiryModalButtonQueryRenderer: React.FC<{
  artworkID: string
  conversationID: string
}> = ({ artworkID, conversationID }) => {
  return (
    <QueryRenderer<OpenInquiryModalButtonQuery>
      environment={defaultEnvironment}
      query={graphql`
        query OpenInquiryModalButtonQuery($artworkID: String!) {
          artwork(id: $artworkID) {
            isOfferableFromInquiry
          }
        }
      `}
      variables={{
        artworkID,
      }}
      cacheConfig={{ force: true }}
      render={({ props, error }): null | JSX.Element => {
        if (error) {
          throw new Error(error.message)
        }

        if (props?.artwork?.isOfferableFromInquiry) {
          return <OpenInquiryModalButton artworkID={artworkID} conversationID={conversationID} />
        } else {
          return null
        }
      }}
    />
  )
}
{'fraction_non_alphanumeric': 0.11277863606267932, 'fraction_numerical': 0.008828073273008165, 'mean_word_length': 2.5854430379746836, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 35, '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': '420272', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1311, 'n_words': 280}