Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EMI-2164): Artsy shipping estimate widget - initial implementation #15126

Merged
merged 11 commits into from
Jan 30, 2025
Prev Previous commit
Next Next commit
chore: render widget link in heading of shipping + tax section
  • Loading branch information
erikdstock committed Jan 29, 2025
commit f6d63fd9902cc6bd75be49d31ab7b864b2c69a0b
61 changes: 45 additions & 16 deletions src/Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Box,
Flex,
Join,
Separator,
Expand All @@ -15,9 +16,19 @@ import { ArtworkSidebarArtistsFragmentContainer } from "./ArtworkSidebarArtists"
import { ArtworkSidebarShippingInformationFragmentContainer } from "./ArtworkSidebarShippingInformation"

import { ContextModule } from "@artsy/cohesion"
import { ArtworkSidebarAuctionPollingRefetchContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarAuctionInfoPolling"
import { ArtworkSidebarAuctionTimerFragmentContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarAuctionTimer"
import { ArtworkSidebarBiddingClosedMessageFragmentContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarBiddingClosedMessage"
import { ArtworkSidebarCommercialButtons } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarCommercialButtons"
import { ArtworkSidebarCreateAlertFragmentContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarCreateAlert"
import { ArtworkSidebarDetailsFragmentContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarDetails"
import { ArtworkSidebarEstimatedValueFragmentContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarEstimatedValue"
import { ArtworkSidebarLinksFragmentContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarLinks"
import { ArtworkSidebarPartnerInfoFragmentContainer } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarPartnerInfo"
import { ArtworkSidebarPrivateArtwork } from "Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarPrivateArtwork"
import { PrivateArtworkAdditionalInfo } from "Apps/Artwork/Components/ArtworkSidebar/PrivateArtworkAdditionalInfo"
import { lotIsClosed } from "Apps/Artwork/Utils/lotIsClosed"
import { ArtsyShippingEstimate } from "Components/ArtsyShippingEstimate"
import { useSystemContext } from "System/Hooks/useSystemContext"
import { SystemQueryRenderer } from "System/Relay/SystemQueryRenderer"
import { useAuctionWebsocket } from "Utils/Hooks/useAuctionWebsocket"
Expand All @@ -26,15 +37,6 @@ import type { ArtworkSidebarQuery } from "__generated__/ArtworkSidebarQuery.grap
import { useState } from "react"
import { ArtworkSidebarArtsyGuarantee } from "./ArtworkSidebarArtsyGuarantee"
import { ArtworkSidebarArtworkTitleFragmentContainer } from "./ArtworkSidebarArtworkTitle"
import { ArtworkSidebarAuctionPollingRefetchContainer } from "./ArtworkSidebarAuctionInfoPolling"
import { ArtworkSidebarAuctionTimerFragmentContainer } from "./ArtworkSidebarAuctionTimer"
import { ArtworkSidebarBiddingClosedMessageFragmentContainer } from "./ArtworkSidebarBiddingClosedMessage"
import { ArtworkSidebarCommercialButtons } from "./ArtworkSidebarCommercialButtons"
import { ArtworkSidebarCreateAlertFragmentContainer } from "./ArtworkSidebarCreateAlert"
import { ArtworkSidebarDetailsFragmentContainer } from "./ArtworkSidebarDetails"
import { ArtworkSidebarEstimatedValueFragmentContainer } from "./ArtworkSidebarEstimatedValue"
import { ArtworkSidebarLinksFragmentContainer } from "./ArtworkSidebarLinks"
import { ArtworkSidebarPartnerInfoFragmentContainer } from "./ArtworkSidebarPartnerInfo"

export interface ArtworkSidebarProps {
artwork: ArtworkSidebar_artwork$data
Expand Down Expand Up @@ -85,6 +87,10 @@ export const ArtworkSidebar: React.FC<

const artworkEcommerceAvailable = !!(isAcquireable || isOfferable)

const globalArtsyShipping =
(artworkEcommerceAvailable && !!artwork.artsyShippingDomestic) ||
!!artwork.artsyShippingInternational

const timerEndAt = sale?.isAuction ? updatedBiddingEndAt : sale?.endAt

const { hasEnded } = useTimer(timerEndAt as string, startAt as string)
Expand Down Expand Up @@ -200,12 +206,33 @@ export const ArtworkSidebar: React.FC<

{!isUnlisted && !isSold && artworkEcommerceAvailable && (
<>
<SidebarExpandable label="Shipping and taxes">
<ArtworkSidebarShippingInformationFragmentContainer
artwork={artwork}
/>
</SidebarExpandable>

{globalArtsyShipping ? (
<Box position="relative" top="-1rem">
<SidebarExpandable
label={
<Flex
position="relative"
top="1rem"
flexDirection="column"
justifyContent={"flex-start"}
>
<Text>Shipping and taxes</Text>
<ArtsyShippingEstimate artwork={artwork} />
</Flex>
}
>
<ArtworkSidebarShippingInformationFragmentContainer
artwork={artwork}
/>
</SidebarExpandable>
</Box>
) : (
<SidebarExpandable label="Shipping and taxes">
<ArtworkSidebarShippingInformationFragmentContainer
artwork={artwork}
/>
</SidebarExpandable>
)}
<Spacer y={1} />
</>
)}
Expand Down Expand Up @@ -260,7 +287,9 @@ export const ArtworkSidebarFragmentContainer = createFragmentContainer(
...ArtworkSidebarPrivateArtwork_artwork
...ArtworkSidebarArtsyGuarantee_artwork
...PrivateArtworkAdditionalInfo_artwork

...ArtsyShippingEstimate_artwork
artsyShippingDomestic
artsyShippingInternational
slug
isSold
isAcquireable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ActionType, type ClickedOnLearnMore } from "@artsy/cohesion"
import { Spacer, Text } from "@artsy/palette"
import { ArtsyShippingEstimate } from "Components/ArtsyShippingEstimate"
import { RouterLink } from "System/Components/RouterLink"
import type { ArtworkSidebarShippingInformation_artwork$data } from "__generated__/ArtworkSidebarShippingInformation_artwork.graphql"
import { createFragmentContainer, graphql } from "react-relay"
Expand All @@ -9,7 +8,6 @@ import { useTracking } from "react-tracking"
export interface ShippingInformationProps {
artwork: ArtworkSidebarShippingInformation_artwork$data
}
const CALCULATED_IN_CHECKOUT_MESSAGE = "Shipping: Calculated in checkout"

const ArtworkSidebarShippingInformation: React.FC<
React.PropsWithChildren<ShippingInformationProps>
Expand All @@ -23,8 +21,6 @@ const ArtworkSidebarShippingInformation: React.FC<
taxInfo,
} = artwork
const { trackEvent } = useTracking()
const globalArtsyShipping =
!!artwork.artsyShippingDomestic || !!artwork.artsyShippingInternational

const handleMoreInfoClick = () => {
const payload: ClickedOnLearnMore = {
Expand Down Expand Up @@ -61,12 +57,6 @@ const ArtworkSidebarShippingInformation: React.FC<
</RouterLink>
</Text>
)}
{globalArtsyShipping && (
<ArtsyShippingEstimate
artwork={artwork}
fallbackText={CALCULATED_IN_CHECKOUT_MESSAGE}
/>
)}
</>
)
}
Expand All @@ -80,7 +70,7 @@ const ArtworkSidebarShippingInformation: React.FC<
</Text>
)}

{!!shippingInfo && !globalArtsyShipping && (
{!!shippingInfo && (
<Text
variant="sm"
color="black60"
Expand All @@ -90,12 +80,6 @@ const ArtworkSidebarShippingInformation: React.FC<
{shippingInfo}
</Text>
)}
{globalArtsyShipping && (
<ArtsyShippingEstimate
artwork={artwork}
fallbackText={CALCULATED_IN_CHECKOUT_MESSAGE}
/>
)}
{!!pickupAvailable && (
<Text variant="sm" color="black60">
Pickup available
Expand Down Expand Up @@ -134,7 +118,6 @@ export const ArtworkSidebarShippingInformationFragmentContainer =
createFragmentContainer(ArtworkSidebarShippingInformation, {
artwork: graphql`
fragment ArtworkSidebarShippingInformation_artwork on Artwork {
...ArtsyShippingEstimate_artwork
isUnlisted
priceIncludesTaxDisplay
shippingOrigin
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Artwork/SidebarExpandable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTracking } from "react-tracking"

export const SidebarExpandable: React.FC<
React.PropsWithChildren<Pick<ExpandableProps, "label" | "children">>
> = ({ label, children }) => {
> = ({ label, children, ...rest }) => {
const { trackEvent } = useTracking()

const handleToggle = (isExpanded: boolean) => {
Expand Down
140 changes: 70 additions & 70 deletions src/__generated__/ArtworkAppTestQuery.graphql.ts

Large diffs are not rendered by default.

Loading