-
Notifications
You must be signed in to change notification settings - Fork 153
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
Conversation
- Load widget with skeleton and fallback text - Still lacking some MP data
#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
Bundle size by type
Bundle analysis report Branch erik.artsy-shipping-widget Project dashboard Generated by RelativeCI Documentation Report issue |
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? | ||
} | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problems with our schema:
category
is deprecated but used to map to values required for estimate- weight not accessible
- location not accessible, so using
shippingOrigin
priceListed
does not includemajor
(see chore: consistent artwork money fields resolver metaphysics#6367)
There was a problem hiding this 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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarShippingInformation.tsx
Outdated
Show resolved
Hide resolved
const artworkValue = (artwork: ShippableArtwork): ArtworkValue | null => { | ||
if (!!artwork.heightCm && !!artwork.widthCm) { | ||
return { | ||
value: artwork.priceListed?.major || 500, // TODO: get a real value |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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 && ( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
src/Apps/Artwork/Components/ArtworkSidebar/ArtworkSidebarShippingInformation.tsx
Outdated
Show resolved
Hide resolved
} | ||
|
||
const loadEstimate = async () => { | ||
console.log("***", "oading estimate", estimateInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔪
Spec fails are legit though and should be fixed before merging. |
There was a problem hiding this 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 👍
@@ -189,6 +189,7 @@ | |||
"yup": "0.32.6" | |||
}, | |||
"devDependencies": { | |||
"@artaio/arta-browser": "^2.16.1", |
There was a problem hiding this comment.
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.
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
console.log()s
in the code - will remove as I finish some of the investigations belowIf required artwork metadata is missing, render a normal fallback shipping availability message (partially complete, want a little more of a guard)Unknowns & followup work
Depends on chore: consistent artwork money fields resolver metaphysics#6367