@graphcommerce/magento-customer 9.0.0-canary.99 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +221 -1174
  2. package/components/AccountAddress/AccountAddress.tsx +3 -2
  3. package/components/AccountAddresses/AccountAddresses.tsx +7 -8
  4. package/components/AccountDeleteForm/AccountDeleteForm.tsx +1 -1
  5. package/components/AccountLatestOrder/AccountLatestOrder.tsx +5 -1
  6. package/components/AccountMenu/AccountMenu.tsx +2 -1
  7. package/components/AccountMenuItem/AccountMenuItem.tsx +7 -6
  8. package/components/AccountOrders/AccountOrders.tsx +3 -2
  9. package/components/AccountSignInUpForm/AccountSignInUpForm.tsx +17 -7
  10. package/components/AddressFields/AddressAddition.tsx +4 -2
  11. package/components/AddressFields/AddressCity.tsx +4 -2
  12. package/components/AddressFields/AddressCountryRegion.tsx +6 -9
  13. package/components/AddressFields/AddressFields.tsx +2 -2
  14. package/components/AddressFields/AddressHouseNumber.tsx +4 -7
  15. package/components/AddressFields/AddressPostcode.tsx +4 -2
  16. package/components/AddressFields/AddressStreet.tsx +3 -2
  17. package/components/AddressFields/useAddressFieldsForm.tsx +2 -6
  18. package/components/AddressMultiLine/AddressMultiLine.tsx +4 -3
  19. package/components/AddressSingleLine/AddressSingleLine.tsx +1 -1
  20. package/components/ApolloCustomerError/ApolloCustomerErrorAlert.tsx +2 -1
  21. package/components/ApolloCustomerError/ApolloCustomerErrorFullPage.tsx +3 -2
  22. package/components/ApolloCustomerError/ApolloCustomerErrorSnackbar.tsx +2 -1
  23. package/components/ApolloCustomerError/useAuthorizationErrorMasked.ts +1 -1
  24. package/components/CancelOrder/CancelOrderForm.tsx +16 -23
  25. package/components/ChangeNameForm/ChangeNameForm.tsx +2 -2
  26. package/components/ChangePasswordForm/ChangePasswordForm.tsx +4 -7
  27. package/components/CompanyFields/CompanyFields.tsx +6 -3
  28. package/components/CompanyFields/CompanyName.tsx +4 -2
  29. package/components/CompanyFields/CompanyVAT.tsx +5 -3
  30. package/components/CompanyFields/useCompanyFieldsForm.tsx +2 -6
  31. package/components/ConfirmCustomer/ConfirmCustomerForm.tsx +3 -16
  32. package/components/ContactForm/ContactForm.tsx +2 -1
  33. package/components/CreateCustomerAddressForm/CreateCustomerAddressForm.tsx +2 -2
  34. package/components/CustomerFab/CustomerFab.tsx +9 -9
  35. package/components/CustomerMenuFabItem/CustomerMenuFabItem.tsx +8 -5
  36. package/components/EditAddressForm/EditAddressForm.tsx +3 -7
  37. package/components/ForgotPasswordForm/ForgotPasswordForm.tsx +11 -8
  38. package/components/GuestOrderOverview/GuestOrderOverviewForm.tsx +2 -1
  39. package/components/NameFields/NameFields.tsx +4 -2
  40. package/components/NoOrdersFound/NoOrdersFound.tsx +4 -3
  41. package/components/OrderCard/OrderCard.tsx +7 -6
  42. package/components/OrderCardItem/OrderCardItem.tsx +4 -0
  43. package/components/OrderCardItemImage/OrderCardItemImage.tsx +4 -3
  44. package/components/OrderDetails/OrderDetails.tsx +11 -10
  45. package/components/OrderDetails/OrderTotals.tsx +6 -4
  46. package/components/OrderItem/OrderItem.tsx +5 -5
  47. package/components/OrderItems/OrderItems.tsx +5 -4
  48. package/components/OrderStateLabel/OrderStateLabel.tsx +4 -2
  49. package/components/OrderStateLabel/OrderStateLabelInline.tsx +4 -3
  50. package/components/ReorderItems/ReorderItems.tsx +2 -2
  51. package/components/ResetPasswordForm/ResetPasswordForm.tsx +7 -8
  52. package/components/SignInForm/SignInForm.tsx +26 -5
  53. package/components/SignInForm/SignInFormInline.tsx +5 -3
  54. package/components/SignOutForm/SignOutForm.tsx +3 -2
  55. package/components/SignOutForm/signOut.ts +3 -2
  56. package/components/SignUpForm/SignUpForm.tsx +20 -4
  57. package/components/SignUpForm/SignUpFormInline.tsx +4 -3
  58. package/components/TrackingLink/TrackingLink.tsx +3 -2
  59. package/components/UpdateCustomerEmailForm/UpdateCustomerEmailForm.tsx +4 -4
  60. package/components/UpdateDefaultAddressForm/UpdateDefaultAddressForm.tsx +1 -1
  61. package/components/ValidatedPasswordElement/ValidatedPasswordElement.tsx +3 -2
  62. package/components/WaitForCustomer/WaitForCustomer.tsx +5 -3
  63. package/components/index.ts +1 -0
  64. package/hooks/index.ts +1 -0
  65. package/hooks/useAccountSignInUpForm.tsx +4 -7
  66. package/hooks/useCustomerQuery.ts +4 -4
  67. package/hooks/useCustomerSession.ts +4 -6
  68. package/hooks/useGuestQuery.ts +4 -4
  69. package/hooks/useOrderCardItemImages.ts +2 -2
  70. package/hooks/useSignInForm.ts +9 -9
  71. package/link/customerLink.ts +6 -11
  72. package/link/xMagentoCacheIdHeader.ts +2 -1
  73. package/package.json +15 -15
  74. package/plugins/MagentoCustomerGraphqlProvider.tsx +2 -2
  75. package/plugins/SessionDebuggerPlugin.tsx +2 -2
  76. package/plugins/XMagentoCacheIdGraphQLProvider.tsx +1 -1
  77. package/plugins/{magentoCustomerGetInContext.ts → magentoCustomerPrivateQueryContext.ts} +7 -4
  78. package/test/authentication.playwright.ts +5 -5
  79. package/typePolicies.ts +3 -1
  80. package/utils/orderState.ts +2 -2
@@ -1,25 +1,24 @@
1
1
  import {
2
- iconPerson,
3
2
  DesktopHeaderBadge,
4
3
  IconSvg,
5
4
  extendableComponent,
5
+ iconPerson,
6
6
  } from '@graphcommerce/next-ui'
7
7
  import { i18n } from '@lingui/core'
8
- import { Fab, FabProps as FabPropsType, NoSsr, SxProps, Theme } from '@mui/material'
8
+ import type { BadgeProps, FabProps as FabPropsType, SxProps, Theme } from '@mui/material'
9
+ import { Fab, NoSsr } from '@mui/material'
9
10
  import React from 'react'
10
- import {
11
- useCustomerAccountCanSignIn,
12
- useCustomerSession,
13
- UseCustomerSessionReturn,
14
- } from '../../hooks'
11
+ import type { UseCustomerSessionReturn } from '../../hooks'
12
+ import { useCustomerAccountCanSignIn, useCustomerSession } from '../../hooks'
15
13
 
16
- type CustomerFabContentProps = {
14
+ export type CustomerFabContentProps = {
17
15
  icon?: React.ReactNode
18
16
  authHref: string
19
17
  guestHref: string
20
18
  FabProps?: Omit<FabPropsType, 'children'>
21
19
  sx?: SxProps<Theme>
22
20
  session?: UseCustomerSessionReturn
21
+ BadgeProps?: BadgeProps
23
22
  }
24
23
 
25
24
  const name = 'CustomerFab'
@@ -27,7 +26,7 @@ const parts = ['root'] as const
27
26
  const { classes } = extendableComponent(name, parts)
28
27
 
29
28
  function CustomerFabContent(props: CustomerFabContentProps) {
30
- const { session, icon, guestHref, authHref, FabProps, sx } = props
29
+ const { session, icon, guestHref, authHref, FabProps, sx, BadgeProps } = props
31
30
 
32
31
  return (
33
32
  <Fab
@@ -45,6 +44,7 @@ function CustomerFabContent(props: CustomerFabContentProps) {
45
44
  color={session?.valid ? 'primary' : 'error'}
46
45
  variant='dot'
47
46
  overlap='circular'
47
+ {...BadgeProps}
48
48
  >
49
49
  {icon ?? <IconSvg src={iconPerson} size='large' />}
50
50
  </DesktopHeaderBadge>
@@ -1,10 +1,13 @@
1
- import { MenuFabSecondaryItem, iconPerson, IconSvg } from '@graphcommerce/next-ui'
2
- import { Badge, NoSsr, SxProps, Theme } from '@mui/material'
3
- import React, { MouseEventHandler } from 'react'
1
+ import { IconSvg, MenuFabSecondaryItem, iconPerson } from '@graphcommerce/next-ui'
2
+ import type { SxProps, Theme } from '@mui/material'
3
+ import { Badge, NoSsr } from '@mui/material'
4
+ import type { MouseEventHandler } from 'react'
5
+ import React from 'react'
4
6
  import { useCustomerAccountCanSignIn } from '../../hooks'
5
- import { useCustomerSession, UseCustomerSessionReturn } from '../../hooks/useCustomerSession'
7
+ import type { UseCustomerSessionReturn } from '../../hooks/useCustomerSession'
8
+ import { useCustomerSession } from '../../hooks/useCustomerSession'
6
9
 
7
- type CustomerMenuFabItemProps = {
10
+ export type CustomerMenuFabItemProps = {
8
11
  icon?: React.ReactNode
9
12
  children: React.ReactNode
10
13
  authHref: string
@@ -4,21 +4,17 @@ import { CountryRegionsDocument } from '@graphcommerce/magento-store'
4
4
  import { Button, Form, FormActions, FormRow } from '@graphcommerce/next-ui'
5
5
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
6
6
  import { Trans } from '@lingui/react'
7
- import { SxProps, Theme } from '@mui/material'
7
+ import type { SxProps, Theme } from '@mui/material'
8
8
  import { useRouter } from 'next/router'
9
- import { AccountAddressFragment } from '../AccountAddress/AccountAddress.gql'
9
+ import type { AccountAddressFragment } from '../AccountAddress/AccountAddress.gql'
10
10
  import { AddressFields } from '../AddressFields/AddressFields'
11
11
  import { CompanyFields } from '../CompanyFields'
12
12
  import { NameFields } from '../NameFields/NameFields'
13
13
  import { UpdateCustomerAddressDocument } from './UpdateCustomerAddress.gql'
14
14
 
15
- type EditAddressFormProps = {
15
+ export type EditAddressFormProps = {
16
16
  address?: AccountAddressFragment
17
17
  sx?: SxProps<Theme>
18
- /**
19
- * @deprecated not used, can be safely removed.
20
- */
21
- onCompleteRoute?: string
22
18
  }
23
19
 
24
20
  export function EditAddressForm(props: EditAddressFormProps) {
@@ -4,16 +4,18 @@ import { emailPattern, useFormGqlMutation } from '@graphcommerce/react-hook-form
4
4
  import { i18n } from '@lingui/core'
5
5
  import { Trans } from '@lingui/react'
6
6
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
- import { Alert, SxProps, Theme } from '@mui/material'
7
+ import type { SxProps, Theme } from '@mui/material'
8
+ import { Alert } from '@mui/material'
8
9
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
9
- import {
10
- ForgotPasswordDocument,
11
- ForgotPasswordMutation,
12
- ForgotPasswordMutationVariables,
13
- } from './ForgotPassword.gql'
10
+ import type { ForgotPasswordMutation, ForgotPasswordMutationVariables } from './ForgotPassword.gql'
11
+ import { ForgotPasswordDocument } from './ForgotPassword.gql'
14
12
 
15
- export function ForgotPasswordForm(props: { sx?: SxProps<Theme> }) {
16
- const { sx = [] } = props
13
+ export type ForgotPasswordFormProps = {
14
+ sx?: SxProps<Theme>
15
+ buttonProps?: React.ComponentProps<typeof Button>
16
+ }
17
+ export function ForgotPasswordForm(props: ForgotPasswordFormProps) {
18
+ const { sx = [], buttonProps } = props
17
19
  const form = useFormGqlMutation<ForgotPasswordMutation, ForgotPasswordMutationVariables>(
18
20
  ForgotPasswordDocument,
19
21
  )
@@ -64,6 +66,7 @@ export function ForgotPasswordForm(props: { sx?: SxProps<Theme> }) {
64
66
  color='primary'
65
67
  variant='pill'
66
68
  size='large'
69
+ {...buttonProps}
67
70
  >
68
71
  <Trans id='Send password reset email' />
69
72
  </Button>
@@ -10,7 +10,8 @@ import { OrderDetails } from '../OrderDetails/OrderDetails'
10
10
  import { OrderTotals } from '../OrderDetails/OrderTotals'
11
11
  import { OrderItems } from '../OrderItems/OrderItems'
12
12
  import { OrderStateLabel } from '../OrderStateLabel/OrderStateLabel'
13
- import { GuestOrderDocument, GuestOrderQueryVariables } from './GuestOrder.gql'
13
+ import type { GuestOrderQueryVariables } from './GuestOrder.gql'
14
+ import { GuestOrderDocument } from './GuestOrder.gql'
14
15
 
15
16
  export function GuestOrderOverviewForm() {
16
17
  const [urlQuery, setUrlQuery] = useUrlQuery<Partial<GuestOrderQueryVariables>>(true)
@@ -1,8 +1,10 @@
1
1
  import { SelectElement, TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
2
  import { FormRow } from '@graphcommerce/next-ui'
3
- import { assertFormGqlOperation, UseFormReturn } from '@graphcommerce/react-hook-form'
3
+ import type { UseFormReturn } from '@graphcommerce/react-hook-form'
4
+ import { assertFormGqlOperation } from '@graphcommerce/react-hook-form'
4
5
  import { i18n } from '@lingui/core'
5
6
  import { Trans } from '@lingui/react'
7
+
6
8
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
9
 
8
10
  type NameFieldValues = {
@@ -11,7 +13,7 @@ type NameFieldValues = {
11
13
  prefix?: string
12
14
  }
13
15
 
14
- type NameFieldProps = {
16
+ export type NameFieldProps = {
15
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
18
  form: UseFormReturn<any>
17
19
  readOnly?: boolean
@@ -1,11 +1,12 @@
1
- import { IconHeader, iconBox, extendableComponent } from '@graphcommerce/next-ui'
1
+ import { IconHeader, extendableComponent, iconBox } from '@graphcommerce/next-ui'
2
2
  import { Trans } from '@lingui/react'
3
- import { Box, SxProps, Theme } from '@mui/material'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Box } from '@mui/material'
4
5
 
5
6
  const parts = ['root'] as const
6
7
  const { classes } = extendableComponent('NoOrdersFound', parts)
7
8
 
8
- type NoOrdersFoundProps = { sx?: SxProps<Theme> }
9
+ export type NoOrdersFoundProps = { sx?: SxProps<Theme> }
9
10
 
10
11
  export function NoOrdersFound(props: NoOrdersFoundProps) {
11
12
  const { sx = [] } = props
@@ -1,13 +1,14 @@
1
1
  import { Money } from '@graphcommerce/magento-store'
2
- import { DateTimeFormat, extendableComponent, NextLink } from '@graphcommerce/next-ui'
3
- import { Box, styled, SxProps, Theme, Skeleton, ListItemButton } from '@mui/material'
4
- import { UseOrderCardItemImages } from '../../hooks/useOrderCardItemImages'
2
+ import { DateTimeFormat, NextLink, extendableComponent } from '@graphcommerce/next-ui'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Box, ListItemButton, Skeleton, styled } from '@mui/material'
5
+ import type { UseOrderCardItemImages } from '../../hooks/useOrderCardItemImages'
5
6
  import { OrderCardItemImage } from '../OrderCardItemImage/OrderCardItemImage'
6
7
  import { OrderStateLabel } from '../OrderStateLabel/OrderStateLabel'
7
8
  import { TrackingLink } from '../TrackingLink/TrackingLink'
8
- import { OrderCardFragment } from './OrderCard.gql'
9
+ import type { OrderCardFragment } from './OrderCard.gql'
9
10
 
10
- type OrderCardProps = Partial<OrderCardFragment> & {
11
+ export type OrderCardProps = Partial<OrderCardFragment> & {
11
12
  loading?: boolean
12
13
  images?: UseOrderCardItemImages
13
14
  sx?: SxProps<Theme>
@@ -102,7 +103,7 @@ export function OrderCard(props: OrderCardProps) {
102
103
  <Box component='span' className={classes.orderMoney} sx={{ fontWeight: 'bold' }}>
103
104
  <Money {...total?.grand_total} />
104
105
  </Box>
105
- <DateTimeFormat>{order_date}</DateTimeFormat>
106
+ <DateTimeFormat date={order_date} />
106
107
  <span>#{number}</span>
107
108
  </OrderRow>
108
109
  <OrderRow>
@@ -6,6 +6,10 @@ export type OrderCardItemProps = OrderCardItemFragment & {
6
6
  thumbnail?: Pick<ProductImage, 'label' | 'url'>
7
7
  }
8
8
 
9
+ /**
10
+ * @deprecated
11
+ * @public
12
+ */
9
13
  export function OrderCardItem(props: OrderCardItemProps) {
10
14
  const { product_sku, product_url_key, thumbnail } = props
11
15
 
@@ -1,13 +1,14 @@
1
1
  import { Image } from '@graphcommerce/image'
2
2
  import { extendableComponent } from '@graphcommerce/next-ui'
3
- import { Box, SxProps, Theme } from '@mui/material'
4
- import { OrderCardItemImageFragment } from '../../hooks/OrderCardItemImage.gql'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Box } from '@mui/material'
5
+ import type { OrderCardItemImageFragment } from '../../hooks/OrderCardItemImage.gql'
5
6
 
6
7
  export type OrderCardItemImageProps = Omit<OrderCardItemImageFragment, 'uid'> & {
7
8
  sx?: SxProps<Theme>
8
9
  }
9
10
 
10
- const componentName = 'OrderCardItemImage' as const
11
+ const componentName = 'OrderCardItemImage'
11
12
  const parts = ['image', 'placeholder'] as const
12
13
  const { classes } = extendableComponent(componentName, parts)
13
14
 
@@ -1,22 +1,23 @@
1
1
  import {
2
- SectionContainer,
3
- iconInvoice,
2
+ DateTimeFormat,
4
3
  IconSvg,
5
- extendableComponent,
4
+ SectionContainer,
6
5
  breakpointVal,
7
- DateTimeFormat,
6
+ extendableComponent,
7
+ iconInvoice,
8
8
  } from '@graphcommerce/next-ui'
9
9
  import { Trans } from '@lingui/macro'
10
- import { Box, SxProps, Theme, Typography, lighten } from '@mui/material'
10
+ import type { SxProps, Theme } from '@mui/material'
11
+ import { Box, Typography, lighten } from '@mui/material'
11
12
  import { AddressMultiLine } from '../AddressMultiLine/AddressMultiLine'
12
13
  import { TrackingLink } from '../TrackingLink/TrackingLink'
13
- import { OrderDetailsFragment } from './OrderDetails.gql'
14
+ import type { OrderDetailsFragment } from './OrderDetails.gql'
14
15
 
15
16
  export type OrderDetailsProps = Partial<OrderDetailsFragment> & {
16
17
  sx?: SxProps<Theme>
17
18
  }
18
19
 
19
- const componentName = 'OrderDetails' as const
20
+ const componentName = 'OrderDetails'
20
21
  const parts = [
21
22
  'sectionContainer',
22
23
  'orderDetailTitle',
@@ -70,9 +71,9 @@ export function OrderDetails(props: OrderDetailsProps) {
70
71
  (theme) => ({
71
72
  gridColumnGap: theme.spacings.xxl,
72
73
  gridRowGap: theme.spacings.md,
73
- display: `grid`,
74
+ display: 'grid',
74
75
  [theme.breakpoints.up('sm')]: {
75
- gridTemplateColumns: `1fr 1fr`,
76
+ gridTemplateColumns: '1fr 1fr',
76
77
  marginTop: theme.spacings.xxs,
77
78
  },
78
79
  }),
@@ -97,7 +98,7 @@ export function OrderDetails(props: OrderDetailsProps) {
97
98
  className={classes.orderDetailTitle}
98
99
  sx={{ '& .SectionHeader-root': { marginTop: 0, paddingBottom: '4px' } }}
99
100
  >
100
- <DateTimeFormat>{order_date}</DateTimeFormat>
101
+ <DateTimeFormat date={order_date} />
101
102
  </SectionContainer>
102
103
  </Box>
103
104
 
@@ -1,14 +1,15 @@
1
1
  import { Money } from '@graphcommerce/magento-store'
2
- import { extendableComponent, breakpointVal } from '@graphcommerce/next-ui'
2
+ import { breakpointVal, extendableComponent } from '@graphcommerce/next-ui'
3
3
  import { Trans } from '@lingui/react'
4
- import { Box, Divider, SxProps, Theme, Typography } from '@mui/material'
5
- import { OrderDetailsFragment } from './OrderDetails.gql'
4
+ import type { SxProps, Theme } from '@mui/material'
5
+ import { Box, Divider, Typography } from '@mui/material'
6
+ import type { OrderDetailsFragment } from './OrderDetails.gql'
6
7
 
7
8
  export type OrderTotalsProps = Partial<OrderDetailsFragment> & {
8
9
  sx?: SxProps<Theme>
9
10
  }
10
11
 
11
- const componentName = 'OrderTotals' as const
12
+ const componentName = 'OrderTotals'
12
13
  const parts = ['totalsContainer', 'totalsRow', 'totalsDivider', 'totalsVat'] as const
13
14
  const { classes } = extendableComponent(componentName, parts)
14
15
 
@@ -77,6 +78,7 @@ export function OrderTotals(props: OrderTotalsProps) {
77
78
  </Box>
78
79
  {total?.taxes?.map((tax) => (
79
80
  <Box
81
+ key={tax?.title}
80
82
  className={classes.totalsVat}
81
83
  sx={(theme) => ({
82
84
  display: 'flex',
@@ -2,17 +2,17 @@ import { Image } from '@graphcommerce/image'
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies
3
3
  import { useProductLink } from '@graphcommerce/magento-product/hooks/useProductLink'
4
4
  import { Money } from '@graphcommerce/magento-store'
5
- import { responsiveVal, extendableComponent, NextLink } from '@graphcommerce/next-ui'
5
+ import { NextLink, extendableComponent, responsiveVal } from '@graphcommerce/next-ui'
6
6
  import { Box } from '@mui/material'
7
- import { OrderCardItemImageFragment } from '../../hooks/OrderCardItemImage.gql'
8
- import { OrderItemFragment } from './OrderItem.gql'
7
+ import type { OrderCardItemImageFragment } from '../../hooks/OrderCardItemImage.gql'
8
+ import type { OrderItemFragment } from './OrderItem.gql'
9
9
 
10
- type OrderItemProps = OrderItemFragment & Omit<OrderCardItemImageFragment, 'uid'>
10
+ export type OrderItemProps = OrderItemFragment & Omit<OrderCardItemImageFragment, 'uid'>
11
11
 
12
12
  const rowImageSize = responsiveVal(70, 110)
13
13
 
14
14
  type OwnerState = { hasOptions: boolean }
15
- const componentName = 'OrderItem' as const
15
+ const componentName = 'OrderItem'
16
16
  const parts = [
17
17
  'root',
18
18
  'itemWithoutOptions',
@@ -1,17 +1,18 @@
1
1
  import { SectionContainer, extendableComponent } from '@graphcommerce/next-ui'
2
2
  import { Trans } from '@lingui/react'
3
- import { Button, Box, SxProps, Theme } from '@mui/material'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Box, Button } from '@mui/material'
4
5
  import { useState } from 'react'
5
- import { UseOrderCardItemImages } from '../../hooks/useOrderCardItemImages'
6
+ import type { UseOrderCardItemImages } from '../../hooks/useOrderCardItemImages'
6
7
  import { OrderItem } from '../OrderItem/OrderItem'
7
- import { OrderItemsFragment } from './OrderItems.gql'
8
+ import type { OrderItemsFragment } from './OrderItems.gql'
8
9
 
9
10
  export type OrderItemsProps = OrderItemsFragment & {
10
11
  images?: UseOrderCardItemImages
11
12
  sx?: SxProps<Theme>
12
13
  }
13
14
 
14
- const componentName = 'OrderItems' as const
15
+ const componentName = 'OrderItems'
15
16
  const parts = ['root', 'orderItemsInnerContainer', 'skeletonOrderItem', 'viewAllButton'] as const
16
17
  const { classes } = extendableComponent(componentName, parts)
17
18
 
@@ -1,7 +1,9 @@
1
1
  import { extendableComponent } from '@graphcommerce/next-ui'
2
2
  import { Trans } from '@lingui/macro'
3
- import { Box, SxProps, Theme } from '@mui/material'
4
- import { OrderStateProps, OrderState, getOrderState } from '../../utils'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Box } from '@mui/material'
5
+ import type { OrderState, OrderStateProps } from '../../utils'
6
+ import { getOrderState } from '../../utils'
5
7
 
6
8
  type OrderStateLabelPropsBase = OrderStateProps
7
9
 
@@ -1,7 +1,8 @@
1
1
  import { alpha } from '@mui/material'
2
- import { OrderStateLabel, OrderStateLabelProps } from './OrderStateLabel'
2
+ import type { OrderStateLabelProps } from './OrderStateLabel'
3
+ import { OrderStateLabel } from './OrderStateLabel'
3
4
 
4
- type OrderStateLabelInlineProps = OrderStateLabelProps
5
+ export type OrderStateLabelInlineProps = OrderStateLabelProps
5
6
 
6
7
  export function OrderStateLabelInline(props: OrderStateLabelInlineProps) {
7
8
  const { sx = [] } = props
@@ -14,7 +15,7 @@ export function OrderStateLabelInline(props: OrderStateLabelInlineProps) {
14
15
  (theme) => ({
15
16
  fontStyle: 'normal',
16
17
  display: 'inline-block',
17
- padding: `0 6px`,
18
+ padding: '0 6px',
18
19
  borderRadius: '3px',
19
20
  fontWeight: 'normal',
20
21
  background: alpha(theme.palette.secondary.main, 0.125),
@@ -1,10 +1,10 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
2
  import { AddProductsToCartSnackbarMessage } from '@graphcommerce/magento-product/components/AddProductsToCart/AddProductsToCartSnackbarMessage'
3
- import { iconChevronRight, IconSvg, LinkOrButton, nonNullable } from '@graphcommerce/next-ui'
3
+ import { IconSvg, LinkOrButton, iconChevronRight, nonNullable } from '@graphcommerce/next-ui'
4
4
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
5
5
  import { Trans } from '@lingui/macro'
6
6
  import { Box } from '@mui/material'
7
- import { OrderItemsFragment } from '../OrderItems/OrderItems.gql'
7
+ import type { OrderItemsFragment } from '../OrderItems/OrderItems.gql'
8
8
  import { ReorderItemsDocument } from './ReorderItems.gql'
9
9
 
10
10
  export type ReorderItemsProps = { order: OrderItemsFragment }
@@ -1,22 +1,20 @@
1
- import { EmailElement, PasswordRepeatElement, TextFieldElement } from '@graphcommerce/ecommerce-ui'
1
+ import { EmailElement, PasswordRepeatElement } from '@graphcommerce/ecommerce-ui'
2
2
  import { Button, Form, FormActions, FormRow } from '@graphcommerce/next-ui'
3
3
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
4
4
  import { Trans } from '@lingui/react'
5
5
  import { useRouter } from 'next/router'
6
6
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
7
7
  import { ValidatedPasswordElement } from '../ValidatedPasswordElement/ValidatedPasswordElement'
8
- import {
9
- ResetPasswordDocument,
10
- ResetPasswordMutation,
11
- ResetPasswordMutationVariables,
12
- } from './ResetPassword.gql'
8
+ import type { ResetPasswordMutation, ResetPasswordMutationVariables } from './ResetPassword.gql'
9
+ import { ResetPasswordDocument } from './ResetPassword.gql'
13
10
 
14
- type ResetPasswordFormProps = {
11
+ export type ResetPasswordFormProps = {
15
12
  token: string
13
+ buttonProps?: React.ComponentProps<typeof Button>
16
14
  }
17
15
 
18
16
  export function ResetPasswordForm(props: ResetPasswordFormProps) {
19
- const { token } = props
17
+ const { token, buttonProps } = props
20
18
 
21
19
  const form = useFormGqlMutation<
22
20
  ResetPasswordMutation,
@@ -83,6 +81,7 @@ export function ResetPasswordForm(props: ResetPasswordFormProps) {
83
81
  color='primary'
84
82
  variant='pill'
85
83
  size='large'
84
+ {...buttonProps}
86
85
  >
87
86
  <Trans id='Save new password' />
88
87
  </Button>
@@ -1,23 +1,44 @@
1
+ import type { UseFormClearErrors, UseFormSetError } from '@graphcommerce/ecommerce-ui'
1
2
  import { PasswordElement } from '@graphcommerce/ecommerce-ui'
2
3
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
3
- import { Button, FormRow, FormActions } from '@graphcommerce/next-ui'
4
+ import { Button, FormActions, FormRow } from '@graphcommerce/next-ui'
5
+ import { t } from '@lingui/macro'
4
6
  import { Trans } from '@lingui/react'
5
- import { Box, FormControl, Link, SxProps, Theme } from '@mui/material'
7
+ import type { SxProps, Theme } from '@mui/material'
8
+ import { Box, FormControl, Link } from '@mui/material'
6
9
  import { useSignInForm } from '../../hooks/useSignInForm'
7
10
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
8
11
 
9
- export type SignInFormProps = { email: string; sx?: SxProps<Theme> }
12
+ export type SignInFormProps = {
13
+ email?: string
14
+ sx?: SxProps<Theme>
15
+ setError: UseFormSetError<{ email?: string; requestedMode?: 'signin' | 'signup' }>
16
+ clearErrors: UseFormClearErrors<{ email?: string; requestedMode?: 'signin' | 'signup' }>
17
+ }
10
18
 
11
19
  export function SignInForm(props: SignInFormProps) {
12
- const { email, sx } = props
20
+ const { email, sx, setError, clearErrors } = props
13
21
 
14
- const form = useSignInForm({ email })
22
+ const form = useSignInForm({
23
+ email,
24
+ onBeforeSubmit(variables) {
25
+ if (!email) {
26
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
27
+ setError('email', { message: t`Please enter a valid email address` })
28
+ return false
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
31
+ clearErrors()
32
+ return variables
33
+ },
34
+ })
15
35
 
16
36
  const { handleSubmit, required, formState, error, control } = form
17
37
  const [remainingError, authError] = graphqlErrorByCategory({
18
38
  category: 'graphql-authentication',
19
39
  error,
20
40
  })
41
+
21
42
  const submitHandler = handleSubmit(() => {})
22
43
 
23
44
  return (
@@ -1,17 +1,19 @@
1
1
  import { PasswordElement } from '@graphcommerce/ecommerce-ui'
2
2
  import { Button, extendableComponent } from '@graphcommerce/next-ui'
3
3
  import { Trans } from '@lingui/react'
4
- import { Box, Link, SxProps, Theme } from '@mui/material'
4
+ import type { SxProps, Theme } from '@mui/material'
5
+ import { Box, Link } from '@mui/material'
5
6
  import { useSignInForm } from '../../hooks/useSignInForm'
6
- import { SignInMutationVariables } from './SignIn.gql'
7
+ import type { SignInMutationVariables } from './SignIn.gql'
7
8
 
8
- type InlineSignInFormProps = Omit<SignInMutationVariables, 'password'> & {
9
+ export type InlineSignInFormProps = Omit<SignInMutationVariables, 'password'> & {
9
10
  sx?: SxProps<Theme>
10
11
  children?: React.ReactNode
11
12
  }
12
13
 
13
14
  const { classes } = extendableComponent('SignInFormInline', ['form', 'button'] as const)
14
15
 
16
+ /** @public */
15
17
  export function SignInFormInline(props: InlineSignInFormProps) {
16
18
  const { email, children, sx = [] } = props
17
19
  const form = useSignInForm({ email })
@@ -1,12 +1,13 @@
1
1
  import { useApolloClient } from '@graphcommerce/graphql'
2
- import { FormState, useFormGqlMutation } from '@graphcommerce/react-hook-form'
2
+ import type { FormState } from '@graphcommerce/react-hook-form'
3
+ import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
3
4
  import { useRouter } from 'next/router'
4
5
  import React from 'react'
5
6
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
6
7
  import { SignOutFormDocument } from './SignOutForm.gql'
7
8
  import { signOut } from './signOut'
8
9
 
9
- type SignOutFormProps = {
10
+ export type SignOutFormProps = {
10
11
  button: (props: { formState: FormState<Record<string, unknown>> }) => React.ReactNode
11
12
  }
12
13
 
@@ -1,8 +1,9 @@
1
- import { ApolloClient } from '@graphcommerce/graphql'
1
+ import type { ApolloClient } from '@graphcommerce/graphql'
2
2
  import { removeCssFlag } from '@graphcommerce/next-ui'
3
3
 
4
4
  export function signOut(client: ApolloClient<object>) {
5
- removeCssFlag('in-context')
5
+ removeCssFlag('private-query')
6
+ globalThis?.sessionStorage?.clear()
6
7
  client.cache.evict({ fieldName: 'currentCartId' })
7
8
  client.cache.evict({ fieldName: 'cart' })
8
9
  client.cache.evict({ fieldName: 'customerToken' })
@@ -3,19 +3,26 @@ import { useQuery } from '@graphcommerce/graphql'
3
3
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
4
4
  import { StoreConfigDocument } from '@graphcommerce/magento-store'
5
5
  import { Button, FormActions, FormRow } from '@graphcommerce/next-ui'
6
+ import type { UseFormClearErrors, UseFormSetError } from '@graphcommerce/react-hook-form'
6
7
  import { FormPersist, useFormGqlMutation } from '@graphcommerce/react-hook-form'
8
+ import { t } from '@lingui/macro'
7
9
  import { Trans } from '@lingui/react'
8
10
  import { Alert } from '@mui/material'
9
11
  import { useSignInForm } from '../../hooks/useSignInForm'
10
12
  import { ApolloCustomerErrorSnackbar } from '../ApolloCustomerError/ApolloCustomerErrorSnackbar'
11
13
  import { NameFields } from '../NameFields/NameFields'
12
14
  import { ValidatedPasswordElement } from '../ValidatedPasswordElement/ValidatedPasswordElement'
13
- import { SignUpDocument, SignUpMutation, SignUpMutationVariables } from './SignUp.gql'
15
+ import type { SignUpMutation, SignUpMutationVariables } from './SignUp.gql'
16
+ import { SignUpDocument } from './SignUp.gql'
14
17
 
15
- type SignUpFormProps = { email: string }
18
+ type SignUpFormProps = {
19
+ email?: string
20
+ setError: UseFormSetError<{ email?: string; requestedMode?: 'signin' | 'signup' }>
21
+ clearErrors: UseFormClearErrors<{ email?: string; requestedMode?: 'signin' | 'signup' }>
22
+ }
16
23
 
17
24
  export function SignUpForm(props: SignUpFormProps) {
18
- const { email } = props
25
+ const { email, setError, clearErrors } = props
19
26
 
20
27
  const storeConfig = useQuery(StoreConfigDocument)
21
28
  const signIn = useSignInForm({ email })
@@ -26,7 +33,16 @@ export function SignUpForm(props: SignUpFormProps) {
26
33
  SignUpDocument,
27
34
  {
28
35
  defaultValues: { email },
29
- onBeforeSubmit: (values) => ({ ...values, email }),
36
+ onBeforeSubmit: (values) => {
37
+ if (!email) {
38
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
39
+ setError('email', { message: t`Please enter a valid email address` })
40
+ return false
41
+ }
42
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
43
+ clearErrors()
44
+ return { ...values, email: email ?? '' }
45
+ },
30
46
  onComplete: async (result, variables) => {
31
47
  if (!result.errors && !storeConfig.data?.storeConfig?.create_account_confirmation) {
32
48
  signIn.setValue('email', variables.email)
@@ -2,16 +2,17 @@ import { ApolloErrorAlert, PasswordRepeatElement } from '@graphcommerce/ecommerc
2
2
  import { useQuery } from '@graphcommerce/graphql'
3
3
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
4
4
  import { StoreConfigDocument } from '@graphcommerce/magento-store'
5
- import { Button, extendableComponent, Form, FormRow } from '@graphcommerce/next-ui'
5
+ import { Button, Form, FormRow, extendableComponent } from '@graphcommerce/next-ui'
6
6
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
7
7
  import { Trans } from '@lingui/react'
8
8
  import { Alert, Box } from '@mui/material'
9
9
  import React from 'react'
10
10
  import { useSignInForm } from '../../hooks/useSignInForm'
11
11
  import { ValidatedPasswordElement } from '../ValidatedPasswordElement/ValidatedPasswordElement'
12
- import { SignUpMutationVariables, SignUpMutation, SignUpDocument } from './SignUp.gql'
12
+ import type { SignUpMutation, SignUpMutationVariables } from './SignUp.gql'
13
+ import { SignUpDocument } from './SignUp.gql'
13
14
 
14
- type SignUpFormInlineProps = Pick<SignUpMutationVariables, 'email'> & {
15
+ export type SignUpFormInlineProps = Pick<SignUpMutationVariables, 'email'> & {
15
16
  children?: React.ReactNode
16
17
  firstname?: string
17
18
  lastname?: string