From 3e91863fd2a516225d0bf00789dac3769c9702be Mon Sep 17 00:00:00 2001 From: Giovanni Schroevers Date: Fri, 3 Jan 2025 17:12:40 +0100 Subject: [PATCH] feat(GCOM-1538): add StoreCredit placeholder component, allow checkout when total of the cart is 0 --- .changeset/smooth-dolls-destroy.md | 8 ++++++++ examples/magento-graphcms/pages/account/index.tsx | 2 ++ examples/magento-graphcms/pages/cart.tsx | 7 +++++-- examples/magento-open-source/.gitignore | 1 + examples/magento-open-source/pages/cart.tsx | 7 +++++-- .../components/CartStartCheckout/CartStartCheckout.tsx | 2 +- .../CartStartCheckout/CartStartCheckoutLinkOrButton.tsx | 2 +- .../StoreCreditAccountMenuItem.tsx | 8 ++++++++ packages/magento-customer/components/index.ts | 1 + 9 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 .changeset/smooth-dolls-destroy.md create mode 100644 packages/magento-customer/components/StoreCreditAccountMenuItem/StoreCreditAccountMenuItem.tsx diff --git a/.changeset/smooth-dolls-destroy.md b/.changeset/smooth-dolls-destroy.md new file mode 100644 index 0000000000..59101d2023 --- /dev/null +++ b/.changeset/smooth-dolls-destroy.md @@ -0,0 +1,8 @@ +--- +'@graphcommerce/magento-graphcms': minor +'@graphcommerce/magento-open-source': minor +'@graphcommerce/magento-cart': minor +'@graphcommerce/magento-customer': minor +--- + +add StoreCredit placeholder component, allow checkout when total of the cart is 0 diff --git a/examples/magento-graphcms/pages/account/index.tsx b/examples/magento-graphcms/pages/account/index.tsx index fcb6f934d2..220133ef00 100644 --- a/examples/magento-graphcms/pages/account/index.tsx +++ b/examples/magento-graphcms/pages/account/index.tsx @@ -8,6 +8,7 @@ import { getCustomerAccountIsDisabled, OrderStateLabelInline, SignOutForm, + StoreCreditAccountMenuItem, useCustomerQuery, WaitForCustomer, } from '@graphcommerce/magento-customer' @@ -126,6 +127,7 @@ function AccountIndexPage() { '&:hover': { background: theme.palette.background.paper }, })} /> + {import.meta.graphCommerce.magentoVersion >= 246 && import.meta.graphCommerce.customerDeleteEnabled && ( - - ({ mt: theme.spacings.md })} /> + ({ position: 'relative', zIndex: 1, mb: theme.spacings.md })} + /> + diff --git a/examples/magento-open-source/.gitignore b/examples/magento-open-source/.gitignore index e71614680e..8e2efc457f 100644 --- a/examples/magento-open-source/.gitignore +++ b/examples/magento-open-source/.gitignore @@ -33,4 +33,5 @@ yarn-error.log* # managed by: graphcommerce pages/.well-known/assetlinks.json.tsx +pages/account/store-credit.tsx # end managed by: graphcommerce diff --git a/examples/magento-open-source/pages/cart.tsx b/examples/magento-open-source/pages/cart.tsx index 4b9f3979fd..ba0fa69c8d 100644 --- a/examples/magento-open-source/pages/cart.tsx +++ b/examples/magento-open-source/pages/cart.tsx @@ -80,8 +80,11 @@ function CartPage() { {hasItems ? ( <> - - ({ mt: theme.spacings.md })} /> + ({ position: 'relative', zIndex: 1, mb: theme.spacings.md })} + /> + diff --git a/packages/magento-cart/components/CartStartCheckout/CartStartCheckout.tsx b/packages/magento-cart/components/CartStartCheckout/CartStartCheckout.tsx index 307fb9395c..7e36ff1475 100644 --- a/packages/magento-cart/components/CartStartCheckout/CartStartCheckout.tsx +++ b/packages/magento-cart/components/CartStartCheckout/CartStartCheckout.tsx @@ -40,7 +40,7 @@ export function CartStartCheckout(props: CartStartCheckoutProps) { } = props const shouldLoginToContinue = useCheckoutShouldLoginToContinue() - const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0 + const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0 || !!cart?.items?.length const hasErrors = cart?.items?.some((item) => (item?.errors?.length ?? 0) > 0) return ( diff --git a/packages/magento-cart/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx b/packages/magento-cart/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx index e63f91be28..02b104865a 100644 --- a/packages/magento-cart/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx +++ b/packages/magento-cart/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx @@ -28,7 +28,7 @@ export function CartStartCheckoutLinkOrButton(props: CartStartCheckoutLinkOrButt const shouldLoginToContinue = useCheckoutShouldLoginToContinue() - const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0 + const hasTotals = (cart?.prices?.grand_total?.value ?? 0) > 0 || !!cart?.items?.length const hasErrors = cart?.items?.some((item) => (item?.errors?.length ?? 0) > 0) return ( diff --git a/packages/magento-customer/components/StoreCreditAccountMenuItem/StoreCreditAccountMenuItem.tsx b/packages/magento-customer/components/StoreCreditAccountMenuItem/StoreCreditAccountMenuItem.tsx new file mode 100644 index 0000000000..a25f26d16b --- /dev/null +++ b/packages/magento-customer/components/StoreCreditAccountMenuItem/StoreCreditAccountMenuItem.tsx @@ -0,0 +1,8 @@ +import type { AccountDashboardQuery } from '../../graphql/AccountDashboard.gql' + +export type StoreCreditAccountMenuItemProps = AccountDashboardQuery + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function StoreCreditAccountMenuItem(props: StoreCreditAccountMenuItemProps) { + return null +} diff --git a/packages/magento-customer/components/index.ts b/packages/magento-customer/components/index.ts index 5384466c2b..9008dd576e 100644 --- a/packages/magento-customer/components/index.ts +++ b/packages/magento-customer/components/index.ts @@ -47,6 +47,7 @@ export * from './SignOutForm/SignOutForm' export * from './SignUpForm/SignUp.gql' export * from './SignUpForm/SignUpForm' export * from './SignUpForm/SignUpFormInline' +export * from './StoreCreditAccountMenuItem/StoreCreditAccountMenuItem' export * from './UpdateCustomerEmailForm/UpdateCustomerEmailForm' export * from './UpdateDefaultAddressForm/UpdateDefaultAddressForm' export * from './WaitForCustomer/WaitForCustomer'