Skip to content

Commit

Permalink
Merge pull request #2048 from graphcommerce-org/feature/enable-config…
Browse files Browse the repository at this point in the history
…urable-options-in-wishlist-GCOM-1188

Feature/enable configurable options in wishlist gcom 1188
  • Loading branch information
paales authored Nov 10, 2023
2 parents 2c95090 + 896b601 commit 01476eb
Show file tree
Hide file tree
Showing 83 changed files with 1,137 additions and 1,189 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-brooms-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-product-configurable': patch
---

When selecitng a non-existing option on a configurable product page, the price would not update.
5 changes: 5 additions & 0 deletions .changeset/empty-ads-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/graphql': patch
---

Include @connection, @export, @defer and @nonreactive in schema, so they can be used, in queries
5 changes: 5 additions & 0 deletions .changeset/flat-emus-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-customer': patch
---

Allow passing skip to useCustomerQuery and useGuestQuery
5 changes: 5 additions & 0 deletions .changeset/fresh-ways-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-product': patch
---

When a product has a discount price, render that on the product page
5 changes: 5 additions & 0 deletions .changeset/red-ghosts-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/next-ui': patch
---

filterNonNullable keys simplified the types which caused unions to be collapsed
5 changes: 5 additions & 0 deletions .changeset/red-poems-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/graphql': patch
---

Allow configurable_product_options_selection to be stored in the localStorage so queries can be resolved correctly
5 changes: 5 additions & 0 deletions .changeset/serious-fishes-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-product': patch
---

The product page will now also load all information that a ProductListItem will load
9 changes: 9 additions & 0 deletions .changeset/tall-tips-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@graphcommerce/magento-product-configurable': minor
'@graphcommerce/magento-product-bundle': minor
'@graphcommerce/magento-wishlist': minor
'@graphcommerce/magento-product': minor
'@graphcommerce/ecommerce-ui': minor
---

Wishlist will now support configurable products and uses the ActionCardLayout
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export function LayoutNavigation(props: LayoutNavigationProps) {
>
<Trans id='Customer Service' />
</MenuFabSecondaryItem>,
<WishlistMenuFabItem key='wishlist' icon={<IconSvg src={iconHeart} size='medium' />}>
<WishlistMenuFabItem
onClick={() => selection.set(false)}
key='wishlist'
icon={<IconSvg src={iconHeart} size='medium' />}
>
<Trans id='Wishlist' />
</WishlistMenuFabItem>,
<DarkLightModeMenuSecondaryItem key='darkmode' />,
Expand Down
6 changes: 3 additions & 3 deletions examples/magento-graphcms/locales/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ msgstr "Schließen Sie die Zahlung auf der Website Ihrer Bank ab."
msgid "Complete your purchase"
msgstr "Schließen Sie Ihren Kauf ab"

msgid "Configure"
msgstr "Konfigurieren"

msgid "Confirm new email"
msgstr "Neue E-Mail bestätigen"

Expand Down Expand Up @@ -319,9 +322,6 @@ msgstr "Heller Modus"
msgid "Loading"
msgstr "Laden"

msgid "Loading wishlist"
msgstr "Wunschliste wird geladen"

msgid "Loading your account"
msgstr "Ihr Kundenkonto wird geladen"

Expand Down
6 changes: 3 additions & 3 deletions examples/magento-graphcms/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ msgstr "Complete the payment on your bank’s website."
msgid "Complete your purchase"
msgstr "Complete your purchase"

msgid "Configure"
msgstr "Configure"

msgid "Confirm new email"
msgstr "Confirm new email"

Expand Down Expand Up @@ -319,9 +322,6 @@ msgstr "Light Mode"
msgid "Loading"
msgstr "Loading"

msgid "Loading wishlist"
msgstr "Loading wishlist"

msgid "Loading your account"
msgstr "Loading your account"

Expand Down
6 changes: 3 additions & 3 deletions examples/magento-graphcms/locales/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ msgstr "Complete el pago en el sitio web de su banco."
msgid "Complete your purchase"
msgstr "Complete su compra"

msgid "Configure"
msgstr "Configurar"

msgid "Confirm new email"
msgstr "Confirmar nuevo correo electrónico"

Expand Down Expand Up @@ -319,9 +322,6 @@ msgstr "Modo claro"
msgid "Loading"
msgstr "Cargando"

msgid "Loading wishlist"
msgstr "Cargando lista de deseos"

msgid "Loading your account"
msgstr "Cargando tu cuenta"

Expand Down
6 changes: 3 additions & 3 deletions examples/magento-graphcms/locales/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ msgstr "Complétez le paiement sur le site de votre banque."
msgid "Complete your purchase"
msgstr "Complétez votre achat"

msgid "Configure"
msgstr "Configurer"

msgid "Confirm new email"
msgstr "Confirmer le nouvel email"

Expand Down Expand Up @@ -319,9 +322,6 @@ msgstr "Mode clair"
msgid "Loading"
msgstr "Chargement"

msgid "Loading wishlist"
msgstr "Chargement de la liste de souhaits"

msgid "Loading your account"
msgstr "Chargement de votre compte"

Expand Down
6 changes: 3 additions & 3 deletions examples/magento-graphcms/locales/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ msgstr "Completa il pagamento sul sito del tuo banco."
msgid "Complete your purchase"
msgstr "Completa il tuo acquisto"

msgid "Configure"
msgstr "Configura"

msgid "Confirm new email"
msgstr "Conferma nuovo indirizzo email"

Expand Down Expand Up @@ -319,9 +322,6 @@ msgstr "Modalità chiara"
msgid "Loading"
msgstr "Caricamento"

msgid "Loading wishlist"
msgstr "Caricamento lista desideri"

msgid "Loading your account"
msgstr "Caricamento del tuo account"

Expand Down
6 changes: 3 additions & 3 deletions examples/magento-graphcms/locales/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ msgstr "Voltooi de betaling op uw bank's website."
msgid "Complete your purchase"
msgstr "Maak uw bestelling compleet"

msgid "Configure"
msgstr "Configureer"

msgid "Confirm new email"
msgstr "Bevestig nieuwe email"

Expand Down Expand Up @@ -319,9 +322,6 @@ msgstr "Lichte modus"
msgid "Loading"
msgstr "Laden"

msgid "Loading wishlist"
msgstr "Ophalen verlanglijst"

msgid "Loading your account"
msgstr "Uw account laden"

Expand Down
4 changes: 2 additions & 2 deletions examples/magento-graphcms/pages/p/[url].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ export const getStaticProps: GetPageStaticProps = async ({ params, locale }) =>
const productPage = staticClient.query({ query: ProductPage2Document, variables: { urlKey } })
const layout = staticClient.query({ query: LayoutDocument, fetchPolicy: 'cache-first' })

const product = productPage.then((pp) =>
pp.data.products?.items?.find((p) => p?.url_key === urlKey),
const product = productPage.then(
(pp) => pp.data.products?.items?.find((p) => p?.url_key === urlKey),
)

const pages = hygraphPageContent(staticClient, 'product/global', product, true)
Expand Down
67 changes: 29 additions & 38 deletions examples/magento-graphcms/pages/wishlist/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { WaitForQueries } from '@graphcommerce/ecommerce-ui'
import { PageOptions } from '@graphcommerce/framer-next-pages'
import { PageMeta, StoreConfigDocument } from '@graphcommerce/magento-store'
import {
WishlistItems,
useWishlistItems,
WishlistItem,
WishlistItemBase,
WishlistItemActionCard,
WishlistItemActionCardProps,
} from '@graphcommerce/magento-wishlist'
import {
GetStaticProps,
Expand All @@ -18,40 +17,48 @@ import {
} from '@graphcommerce/next-ui'
import { i18n } from '@lingui/core'
import { Trans } from '@lingui/react'
import { Container } from '@mui/material'
import { CircularProgress, Container, Theme, useMediaQuery } from '@mui/material'
import { LayoutOverlay, LayoutOverlayProps } from '../../components'
import { graphqlSharedClient } from '../../lib/graphql/graphqlSsrClient'

type Props = Record<string, unknown>
type GetPageStaticProps = GetStaticProps<LayoutOverlayProps, Props>

function WishlistPage() {
const wishlistItemsData = useWishlistItems()
const wishlistItems = useWishlistItems()

const isMobile = useMediaQuery<Theme>((theme) => theme.breakpoints.down('md'), {
defaultMatches: false,
})

const size: WishlistItemActionCardProps['size'] = isMobile ? 'small' : 'large'

return (
<>
<PageMeta title={i18n._(/* i18n */ 'Wishlist')} metaRobots={['noindex']} />
<LayoutOverlayHeader>
<LayoutTitle component='span' size='small'>
<LayoutOverlayHeader
switchPoint={0}
noAlign
sx={(theme) => ({
'&.noAlign': { marginBottom: theme.spacings.sm },
'& + .MuiContainer-root': { marginBottom: theme.spacings.sm },
})}
>
<LayoutTitle component='span' size='small' icon={iconHeart}>
<Trans id='Wishlist' />
</LayoutTitle>
</LayoutOverlayHeader>

<WaitForQueries
waitFor={[wishlistItemsData]}
waitFor={[wishlistItems]}
fallback={
<Container maxWidth='md'>
<FullPageMessage
title={<Trans id='Loading wishlist' />}
icon={<IconSvg src={iconHeart} size='xxl' />}
>
<Trans id='We are fetching your favorite products, one moment please!' />
</FullPageMessage>
</Container>
<FullPageMessage title={<Trans id='Loading' />} icon={<CircularProgress />}>
<Trans id='We are fetching your favorite products, one moment please!' />
</FullPageMessage>
}
>
<Container maxWidth='md'>
{!wishlistItemsData.data || wishlistItemsData.data.length === 0 ? (
{wishlistItems.items.length === 0 ? (
<FullPageMessage
title={<Trans id='Your wishlist is empty' />}
icon={<IconSvg src={iconHeart} size='xxl' />}
Expand All @@ -63,29 +70,13 @@ function WishlistPage() {
>
<Trans id='Discover our collection and add items to your wishlist!' />
</FullPageMessage>
) : null}

{wishlistItemsData.data && wishlistItemsData.data.length > 0 ? (
) : (
<>
<LayoutTitle icon={iconHeart}>
<Trans id='Wishlist' />
</LayoutTitle>
<Container maxWidth='md'>
<WishlistItems
renderer={{
BundleProduct: WishlistItemBase,
ConfigurableProduct: WishlistItemBase,
DownloadableProduct: WishlistItemBase,
SimpleProduct: WishlistItem,
VirtualProduct: WishlistItem,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore GiftCardProduct is only available in Commerce
GiftCardProduct: WishlistItemBase,
}}
/>
</Container>
{wishlistItems.items.map((item) => (
<WishlistItemActionCard key={item.id} item={item} size={size} />
))}
</>
) : null}
)}
</Container>
</WaitForQueries>
</>
Expand Down
1 change: 1 addition & 0 deletions graphql.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
MagentoGraphCms: {
schema: [
'examples/magento-graphcms/.mesh/schema.graphql',
'packages/graphql/apollo-client.graphql',
'packagesDev/graphql-codegen-near-operation-file/src/directive/env.graphqls',
'packagesDev/graphql-codegen-near-operation-file/src/directive/injectable.graphqls',
],
Expand Down
26 changes: 25 additions & 1 deletion packages/graphql/apollo-client.graphql
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
"Indicates that the client should resolve the field value locally as part of a query, e.g. in a React component"
"""
The @client directive allows you to resolve client-only data alongside your server data. These fields are not sent to the GraphQL server.
"""
directive @client on FIELD

"""
The @connection directive allows you to specify a custom cache key for paginated results. For more information, see this section on the [@connection directive](https://www.apollographql.com/docs/react/caching/advanced-topics/#the-connection-directive).
"""
directive @connection(key: String, filter: [String]) on FIELD

"""
This directive enables your queries to receive data for specific fields incrementally, instead of receiving all field data at the same time. This is helpful whenever some fields in a query take much longer to resolve than others.
"""
directive @defer(if: Boolean! = true, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT

# """
# Directs the executor to stream plural fields when the `if` argument is true or undefined.
# """
# directive @stream(if: Boolean! = true, label: String, initialCount: Int! = 0) on FIELD

directive @export(exportName: String!) on FIELD

"""
The @nonreactive directive can be used to mark query fields or fragment spreads and is used to indicate that changes to the data contained within the subtrees marked @nonreactive should not trigger rerendering.
"""
directive @nonreactive on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const persistenceMapper = (data: string): Promise<string> => {
'ROOT_QUERY.checkoutAgreements',
'ROOT_QUERY.storeConfig',
'ROOT_QUERY.__type*',
'ConfigurableProduct:*.configurable_product_options_selection*',
'*Product:{"uid":"*"}.crosssell_products',
])

Expand Down
2 changes: 1 addition & 1 deletion packages/magento-customer/hooks/useCustomerQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export function useCustomerQuery<Q, V extends OperationVariables>(
options: QueryHookOptions<Q, V> = {},
): QueryResult<Q, V> {
const { loggedIn } = useCustomerSession()
return useQuery(document, { ...options, ssr: false, skip: !loggedIn })
return useQuery(document, { ...options, ssr: false, skip: options.skip || !loggedIn })
}
2 changes: 1 addition & 1 deletion packages/magento-customer/hooks/useGuestQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export function useGuestQuery<Q, V extends OperationVariables>(
queryOptions: QueryHookOptions<Q, V> = {},
) {
const { token } = useCustomerSession()
return useQuery(document, { ...queryOptions, ssr: false, skip: !!token })
return useQuery(document, { ...queryOptions, ssr: false, skip: queryOptions.skip || !!token })
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const compName = 'ConfigurableOptionsInput' as const
const parts = ['form', 'button', 'finalPrice', 'quantity', 'divider', 'buttonWrapper'] as const
const { classes } = extendableComponent(compName, parts)

/**
* @deprecated
*/
export function ConfigurableProductAddToCart(props: ConfigurableProductAddToCartProps) {
const {
name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fragment ConfigurableOptions on ConfigurableProduct {
fragment ConfigurableOptions on ConfigurableProduct @injectable {
__typename
uid
sku
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ export function useConfigurableOptionsForSelection(variables: UseConfigurableOpt
skip: !url_key || !selectedOptions.length,
})

const configured = findByTypename(
selection.data?.products?.items ?? selection.previousData?.products?.items,
'ConfigurableProduct',
)
const configured = selection.error
? undefined
: findByTypename(
selection.data?.products?.items ?? selection.previousData?.products?.items,
'ConfigurableProduct',
)
return { ...selection, configured }
}

Expand Down
Loading

0 comments on commit 01476eb

Please sign in to comment.