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

Conversation

erikdstock
Copy link
Contributor

@erikdstock erikdstock commented Jan 28, 2025

The type of this PR is: FEAT
This PR solves EMI-2164

Description

This PR is the initial implementation of the shipping estimate widget to be shown in the shipping & taxes section of an artwork page. It does not contain widget styling and will need some more changes to work fully.

Note on context provider
Due to specifics of how we load the browser-only shipping estimate module, it is not available at the moment the page renders. This makes the loading async, a problem that snowballs because the widget is hidden in a Collapsing element. My initial solution was to create a whole context to load the module outside of the Collapse, but there is still an async-ness to loading the widget link itself, so it might be worth removing this extra complexity for the two separate layers of loading.

A/C

  • Attempt to load the widget on artworks with global (domestic/international) artsy shipping enabled
  • Support artworks with no edition sets
  • There are still console.log()s in the code - will remove as I finish some of the investigations below
  • If required artwork metadata is missing, render a normal fallback shipping availability message (partially complete, want a little more of a guard)
  • Tests (initial tests are done)

Unknowns & followup work

- Load widget with skeleton and fallback text
- Still lacking some MP data
Copy link

relativeci bot commented Jan 28, 2025

#1640 Bundle Size — 9.01MiB (+0.74%).

4374b12(current) vs 56d5d43 main#1636(baseline)

Warning

Bundle contains 14 duplicate packages – View duplicate packages

Bundle metrics  Change 4 changes Regression 1 regression
                 Current
#1640
     Baseline
#1636
Regression  Initial JS 3.65MiB(+0.78%) 3.62MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 97.74% 50.38%
No change  Chunks 105 105
No change  Assets 108 108
Change  Modules 5851(+0.02%) 5850
No change  Duplicate Modules 523 523
Change  Duplicate Code 4%(+0.25%) 3.99%
No change  Packages 266 266
No change  Duplicate Packages 13 13
Bundle size by type  Change 2 changes Regression 2 regressions
                 Current
#1640
     Baseline
#1636
Regression  JS 8.87MiB (+100%) undefined
Regression  Other 147.32KiB (+100%) undefined

Bundle analysis reportBranch erik.artsy-shipping-widgetProject dashboard


Generated by RelativeCIDocumentationReport issue

Comment on lines 189 to 208
const ARTWORK_FRAGMENT = graphql`
fragment ArtsyShippingEstimate_artwork on Artwork {
isFramed
category # Raw category required for mapping to Arta subtype
shippingOrigin
shippingCountry
location {
country
postalCode
city
}
priceCurrency
priceListed {
major
}
heightCm
widthCm
# shippingWeight # may need to be added?
}
`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problems with our schema:

Copy link
Member

@oxaudo oxaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are immediate comments but maybe worth pairing on it tomorrow AM.

</Text>
)}
<ArtworkSidebarArtistsFragmentContainer artwork={artwork} />
<ArtsyShippingEstimateProvider>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... This seems off to me that the whole sidebar is wrapped into this provider. Wonder if we can make it more local and only wrap the relevant section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove the provider, agree it's not needed here

const { trackEvent } = useTracking()
const globalArtsyShipping =
!!artwork.artsyShippingDomestic || !!artwork.artsyShippingInternational
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this is an accurate condition that we want here. Believe it has to be !!artwork.artsyShippingDomestic && (!!artwork.artsyShippingInternational || (!artwork.artsyShippingInternationa && !artwork.international_shipping_fee)). So either arta shipping both domestic and international or arta domestic and international not configured.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow up on this in person, i believe you have the expertise and it's a small change if so

import { useTracking } from "react-tracking"

export interface ShippingInformationProps {
artwork: ArtworkSidebarShippingInformation_artwork$data
}
const CALCULATED_IN_CHECKOUT_MESSAGE = "Shipping: Calculated in checkout"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the case any more after this pr: artsy/metaphysics#6383

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing for now bc designs don't need it

const artworkValue = (artwork: ShippableArtwork): ArtworkValue | null => {
if (!!artwork.heightCm && !!artwork.widthCm) {
return {
value: artwork.priceListed?.major || 500, // TODO: get a real value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think price_listed is the backend price that is not exposed publicly so I guess users will not be able to see this. Also, do we aim to support artworks displayed as price range, etc? (sorry if I missed the product requirements)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point @starsirius! I believe there was not a discussion about excluding range works. And I forgot about this whole 'price being private' for MO sometimes. Think taking midpoint makes sense here but def something to discuss.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is the right field for public facing pricing. Confusing indeed!

- dont render if estimate creation fails
- earlier check for feature flag
- close widget when navigating away
- initial widget link styling
oxaudo
oxaudo previously approved these changes Jan 30, 2025
Copy link
Member

@oxaudo oxaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel good now if we merge this and continue iterating. Comments are mostly to remember where some clean up needed.

label={
<Flex flexDirection="column" justifyContent="flex-start">
<Text>Shipping and taxes</Text>
{globalArtsyShipping && artsyShippingEstimateEnabled && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like that all the guarding is scoped to this one place! Thanks for the update.

)}
</Flex>
}
>
<ArtworkSidebarShippingInformationFragmentContainer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in person - we are not hiding the actual shippingInfo line in expanded section of this view. We can definitely do it - just don't think it's adding anything to the test and believe keeping code less intermingled with the estimate test here is a good goal. Might still be worth confirming out assumption with Cami and Vivi.

}

const loadEstimate = async () => {
console.log("***", "oading estimate", estimateInput)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪

@oxaudo
Copy link
Member

oxaudo commented Jan 30, 2025

Spec fails are legit though and should be fixed before merging.

damassi
damassi previously approved these changes Jan 30, 2025
Copy link
Member

@damassi damassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current refactor / simplification is much improved 👍

@erikdstock erikdstock dismissed stale reviews from damassi and oxaudo via 50838b6 January 30, 2025 19:35
@@ -189,6 +189,7 @@
"yup": "0.32.6"
},
"devDependencies": {
"@artaio/arta-browser": "^2.16.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added here for the types - the lib is downloaded by script.

@erikdstock erikdstock merged commit d53b113 into main Jan 30, 2025
11 checks passed
@erikdstock erikdstock deleted the erik.artsy-shipping-widget branch January 30, 2025 20:22
@artsy-peril artsy-peril bot mentioned this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants