Skip to content

Commit

Permalink
feat: don't render primary label when there is a partner offer
Browse files Browse the repository at this point in the history
This depends on MP change that removes partner offers from primary
labels. Primary label should only consist of unauthenticated data.
  • Loading branch information
starsirius committed Nov 11, 2024
1 parent c172c74 commit 8b7c310
Show file tree
Hide file tree
Showing 149 changed files with 10,136 additions and 5,810 deletions.
13 changes: 9 additions & 4 deletions src/Components/Artwork/Details/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SaveButtonQueryRenderer } from "Components/Artwork/SaveButton/SaveButto
import { ConsignmentSubmissionStatusFragmentContainer } from "Components/Artwork/ConsignmentSubmissionStatus"
import HighDemandIcon from "@artsy/icons/HighDemandIcon"
import { BidTimerLine } from "./BidTimerLine"
import { PrimaryLabelLine } from "Components/Artwork/Details/PrimaryLabelLine"
import { PrimaryLabelLineQueryRenderer } from "Components/Artwork/Details/PrimaryLabelLine"
import { PartnerOfferLineQueryRenderer } from "./PartnerOfferLine"
import { PartnerOfferedPriceQueryRenderer } from "./PartnerOfferedPrice"

Expand Down Expand Up @@ -295,8 +295,8 @@ export const Details: React.FC<DetailsProps> = ({
const isAuction = rest?.artwork?.sale?.is_auction ?? false
const artworkId = rest?.artwork?.internalID

const showPrimaryLabelLine: boolean =
!!rest?.artwork?.collectorSignals?.primaryLabel && !isAuction
const primaryLabel = rest?.artwork?.collectorSignals?.primaryLabel
const showPrimaryLabelLine: boolean = !!primaryLabel && !isAuction

// FIXME: Extract into a real component
const renderSaveButtonComponent = () => {
Expand Down Expand Up @@ -351,7 +351,12 @@ export const Details: React.FC<DetailsProps> = ({
maxWidth={showPrimaryLabelLine ? "95%" : "75%"}
overflow="hidden"
>
{showPrimaryLabelLine && <PrimaryLabelLine artwork={rest.artwork} />}
{showPrimaryLabelLine && (
<PrimaryLabelLineQueryRenderer
id={artworkId}
label={primaryLabel}
/>
)}
{!hideArtistName && (
<ArtistLine showSaveButton={showSaveButton} {...rest} />
)}
Expand Down
78 changes: 65 additions & 13 deletions src/Components/Artwork/Details/PrimaryLabelLine.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import { useArtworkGridContext } from "Components/ArtworkGrid/ArtworkGridContext"
import { Text } from "@artsy/palette"
import { graphql, useFragment } from "react-relay"
import { graphql, createFragmentContainer } from "react-relay"
import { PrimaryLabelLine_artwork$key } from "__generated__/PrimaryLabelLine_artwork.graphql"
import { FC } from "react"
import { SystemQueryRenderer } from "System/Relay/SystemQueryRenderer"
import { PrimaryLabelLineQuery } from "__generated__/PrimaryLabelLineQuery.graphql"

interface PrimaryLabelLineProps {
artwork: PrimaryLabelLine_artwork$key
label: string | null | undefined
artwork?: PrimaryLabelLine_artwork$key
}

export const PrimaryLabelLine: React.FC<PrimaryLabelLineProps> = ({
label,
artwork,
}) => {
const data = useFragment(primaryLabelLineFragment, artwork)
const primaryLabel = data.collectorSignals?.primaryLabel
const { hideSignals } = useArtworkGridContext()
const partnerOffer = artwork?.collectorSignals?.partnerOffer

if (!primaryLabel) {
if (!label || !!partnerOffer) {
return null
}

if (primaryLabel === "INCREASED_INTEREST" && !hideSignals) {
if (label === "INCREASED_INTEREST" && !hideSignals) {
return (
<Text
variant="xs"
Expand All @@ -36,7 +40,7 @@ export const PrimaryLabelLine: React.FC<PrimaryLabelLineProps> = ({
)
}

if (primaryLabel === "CURATORS_PICK" && !hideSignals) {
if (label === "CURATORS_PICK" && !hideSignals) {
return (
<Text
variant="xs"
Expand All @@ -57,10 +61,58 @@ export const PrimaryLabelLine: React.FC<PrimaryLabelLineProps> = ({
return null
}

const primaryLabelLineFragment = graphql`
fragment PrimaryLabelLine_artwork on Artwork {
collectorSignals {
primaryLabel
}
export const PrimaryLabelLineFragmentContainer = createFragmentContainer(
PrimaryLabelLine,
{
artwork: graphql`
fragment PrimaryLabelLine_artwork on Artwork {
collectorSignals {
primaryLabel
partnerOffer {
endAt
priceWithDiscount {
display
}
}
}
}
`,
}
`
)

interface PrimaryLabelLineQueryRendererProps {
id: string
label: string | null | undefined
}

export const PrimaryLabelLineQueryRenderer: FC<PrimaryLabelLineQueryRendererProps> = ({
id,
label,
}) => {
return (
<SystemQueryRenderer<PrimaryLabelLineQuery>
lazyLoad
query={graphql`
query PrimaryLabelLineQuery($id: String!) {
artwork(id: $id) {
...PrimaryLabelLine_artwork
}
}
`}
placeholder={<PrimaryLabelLine label={label} />}
variables={{ id }}
render={({ error, props }) => {
if (error || !props?.artwork) {
return <PrimaryLabelLine label={label} />
}

return (
<PrimaryLabelLineFragmentContainer
label={label}
artwork={props.artwork}
/>
)
}}
/>
)
}
Loading

0 comments on commit 8b7c310

Please sign in to comment.