@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,10 +1,11 @@
1
1
  import { extendableComponent } from '@graphcommerce/next-ui'
2
2
  import { Trans } from '@lingui/react'
3
- import { Box, Link, SxProps, Theme } from '@mui/material'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Box, Link } from '@mui/material'
4
5
  import { AddressMultiLine } from '../AddressMultiLine/AddressMultiLine'
5
6
  import { DeleteCustomerAddressForm } from '../DeleteCustomerAddressForm/DeleteCustomerAddressForm'
6
7
  import { UpdateDefaultAddressForm } from '../UpdateDefaultAddressForm/UpdateDefaultAddressForm'
7
- import { AccountAddressFragment } from './AccountAddress.gql'
8
+ import type { AccountAddressFragment } from './AccountAddress.gql'
8
9
 
9
10
  export type AccountAddressProps = AccountAddressFragment & { sx?: SxProps<Theme> }
10
11
 
@@ -1,21 +1,22 @@
1
1
  import {
2
2
  FullPageMessage,
3
- SectionContainer,
4
- iconHome,
5
3
  IconSvg,
4
+ SectionContainer,
6
5
  extendableComponent,
6
+ iconHome,
7
7
  } from '@graphcommerce/next-ui'
8
8
  import { Trans } from '@lingui/react'
9
- import { Skeleton, Button, Box, Theme, SxProps } from '@mui/material'
9
+ import type { SxProps, Theme } from '@mui/material'
10
+ import { Box, Button, Skeleton } from '@mui/material'
10
11
  import { AccountAddress } from '../AccountAddress/AccountAddress'
11
- import { AccountAddressesFragment } from './AccountAddresses.gql'
12
+ import type { AccountAddressesFragment } from './AccountAddresses.gql'
12
13
 
13
14
  export type AccountAddressesProps = AccountAddressesFragment & {
14
15
  loading: boolean
15
16
  sx?: SxProps<Theme>
16
17
  }
17
18
 
18
- const name = 'AccountAddresses' as const
19
+ const name = 'AccountAddresses'
19
20
  const parts = ['root', 'addresses', 'button', 'link'] as const
20
21
  const { classes } = extendableComponent(name, parts)
21
22
 
@@ -75,9 +76,7 @@ export function AccountAddresses(props: AccountAddressesProps) {
75
76
  className={classes.addresses}
76
77
  sx={(theme) => ({ '& > div': { borderBottom: `1px solid ${theme.palette.divider}` } })}
77
78
  >
78
- {addresses?.map((address) => (
79
- <AccountAddress key={address?.id} {...address} />
80
- ))}
79
+ {addresses?.map((address) => <AccountAddress key={address?.id} {...address} />)}
81
80
  </Box>
82
81
 
83
82
  <Button
@@ -1,6 +1,6 @@
1
1
  import { CheckboxElement, EmailElement } from '@graphcommerce/ecommerce-ui'
2
2
  import { useApolloClient, useMutation } from '@graphcommerce/graphql'
3
- import { FormActions, FormRow, Button } from '@graphcommerce/next-ui'
3
+ import { Button, FormActions, FormRow } from '@graphcommerce/next-ui'
4
4
  import { useForm } from '@graphcommerce/react-hook-form'
5
5
  import { Trans, t } from '@lingui/macro'
6
6
  import { Box, Typography } from '@mui/material'
@@ -1,7 +1,7 @@
1
1
  import { SectionContainer } from '@graphcommerce/next-ui'
2
2
  import React from 'react'
3
3
  import useOrderCardItemImages from '../../hooks/useOrderCardItemImages'
4
- import { AccountOrdersFragment } from '../AccountOrders/AccountOrders.gql'
4
+ import type { AccountOrdersFragment } from '../AccountOrders/AccountOrders.gql'
5
5
  import { NoOrdersFound } from '../NoOrdersFound/NoOrdersFound'
6
6
  import { OrderCard } from '../OrderCard/OrderCard'
7
7
 
@@ -9,6 +9,10 @@ export type AccountLatestOrderProps = AccountOrdersFragment & {
9
9
  loading: boolean
10
10
  }
11
11
 
12
+ /**
13
+ * @deprecated
14
+ * @public
15
+ */
12
16
  export function AccountLatestOrder(props: AccountLatestOrderProps) {
13
17
  const { orders, loading } = props
14
18
  const latestOrderCard = orders?.items?.[(orders?.items?.length ?? 1) - 1]
@@ -1,5 +1,6 @@
1
1
  import { extendableComponent } from '@graphcommerce/next-ui'
2
- import { List, SxProps, Theme } from '@mui/material'
2
+ import type { SxProps, Theme } from '@mui/material'
3
+ import { List } from '@mui/material'
3
4
  import React from 'react'
4
5
 
5
6
  export type AccountMenuProps = { children: React.ReactNode; sx?: SxProps<Theme> }
@@ -1,13 +1,14 @@
1
- import { ImageProps } from '@graphcommerce/image'
1
+ import type { ImageProps } from '@graphcommerce/image'
2
+ import type { ButtonProps } from '@graphcommerce/next-ui'
2
3
  import {
3
- responsiveVal,
4
- iconChevronRight,
5
- IconSvg,
6
4
  Button,
7
- ButtonProps,
5
+ IconSvg,
8
6
  extendableComponent,
7
+ iconChevronRight,
8
+ responsiveVal,
9
9
  } from '@graphcommerce/next-ui'
10
- import { ListItem, ListItemIcon, ListItemText, SxProps, Theme } from '@mui/material'
10
+ import type { SxProps, Theme } from '@mui/material'
11
+ import { ListItem, ListItemIcon, ListItemText } from '@mui/material'
11
12
  import React from 'react'
12
13
 
13
14
  export type AccountMenuItemProps = {
@@ -1,11 +1,12 @@
1
1
  import { Pagination, SectionContainer, extendableComponent } from '@graphcommerce/next-ui'
2
2
  import { Trans } from '@lingui/react'
3
- import { Box, Link, SxProps, Theme } from '@mui/material'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Box, Link } from '@mui/material'
4
5
  import React from 'react'
5
6
  import useOrderCardItemImages from '../../hooks/useOrderCardItemImages'
6
7
  import { NoOrdersFound } from '../NoOrdersFound/NoOrdersFound'
7
8
  import { OrderCard } from '../OrderCard/OrderCard'
8
- import { AccountOrdersFragment } from './AccountOrders.gql'
9
+ import type { AccountOrdersFragment } from './AccountOrders.gql'
9
10
 
10
11
  export type AccountOrdersProps = AccountOrdersFragment & { sx?: SxProps<Theme> }
11
12
 
@@ -3,16 +3,22 @@ import { useApolloClient } from '@graphcommerce/graphql'
3
3
  import {
4
4
  ActionCard,
5
5
  Button,
6
+ extendableComponent,
6
7
  FormActions,
7
8
  FormDiv,
8
9
  FormRow,
9
10
  LayoutTitle,
10
- extendableComponent,
11
11
  } from '@graphcommerce/next-ui'
12
12
  import { Trans } from '@lingui/react'
13
- import { Alert, Box, CircularProgress, Link, SxProps, Theme, Typography } from '@mui/material'
13
+ import type { SxProps, Theme } from '@mui/material'
14
+ import { Alert, Box, CircularProgress, Link, Typography } from '@mui/material'
14
15
  import { useRouter } from 'next/router'
15
- import { CustomerDocument, useAccountSignInUpForm, useCustomerAccountCanSignUp } from '../../hooks'
16
+ import {
17
+ CustomerDocument,
18
+ useAccountSignInUpForm,
19
+ useCustomerAccountCanSignUp,
20
+ UseCustomerValidateTokenDocument,
21
+ } from '../../hooks'
16
22
  import { useCustomerQuery } from '../../hooks/useCustomerQuery'
17
23
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError'
18
24
  import { SignInForm } from '../SignInForm/SignInForm'
@@ -29,12 +35,14 @@ const { classes } = extendableComponent('AccountSignInUpForm', parts)
29
35
 
30
36
  export function AccountSignInUpForm(props: AccountSignInUpFormProps) {
31
37
  const { sx = [], signUpDisabled } = props
38
+ const customerEmailQuery = useCustomerQuery(UseCustomerValidateTokenDocument)
32
39
  const customerQuery = useCustomerQuery(CustomerDocument)
33
40
 
34
- const { email, firstname = '' } = customerQuery.data?.customer ?? {}
41
+ const { email } = customerEmailQuery.data?.customer ?? {}
42
+ const { firstname = '' } = customerQuery.data?.customer ?? {}
35
43
 
36
44
  const { mode, form, submit } = useAccountSignInUpForm()
37
- const { formState, watch, control, error } = form
45
+ const { formState, control, error, setError, clearErrors, watch } = form
38
46
  const router = useRouter()
39
47
 
40
48
  const client = useApolloClient()
@@ -48,6 +56,8 @@ export function AccountSignInUpForm(props: AccountSignInUpFormProps) {
48
56
  mode === 'signin' ||
49
57
  (mode === 'signup' && canSignUp)
50
58
 
59
+ const emailValue = watch('email')
60
+
51
61
  return (
52
62
  <FormDiv sx={sx} className={classes.root}>
53
63
  <Box
@@ -200,13 +210,13 @@ export function AccountSignInUpForm(props: AccountSignInUpFormProps) {
200
210
 
201
211
  {(mode === 'signin' || mode === 'session-expired') && (
202
212
  <Box>
203
- <SignInForm email={watch('email')} />
213
+ <SignInForm email={emailValue} setError={setError} clearErrors={clearErrors} />
204
214
  </Box>
205
215
  )}
206
216
 
207
217
  {mode === 'signup' && canSignUp && (
208
218
  <Box>
209
- <SignUpForm email={watch('email')} />
219
+ <SignUpForm email={emailValue} setError={setError} clearErrors={clearErrors} />
210
220
  </Box>
211
221
  )}
212
222
  {mode === 'signup' && !canSignUp && (
@@ -1,6 +1,8 @@
1
- import { TextFieldElement, FieldValues, FieldPath } from '@graphcommerce/ecommerce-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
3
  import { Trans } from '@lingui/react'
3
- import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
4
+ import type { AddressFieldsOptions } from './useAddressFieldsForm'
5
+ import { useAddressFieldsForm } from './useAddressFieldsForm'
4
6
 
5
7
  export function AddressAddition<
6
8
  TFieldValues extends FieldValues = FieldValues,
@@ -1,6 +1,8 @@
1
- import { TextFieldElement, FieldValues, FieldPath } from '@graphcommerce/ecommerce-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
3
  import { Trans } from '@lingui/react'
3
- import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
4
+ import type { AddressFieldsOptions } from './useAddressFieldsForm'
5
+ import { useAddressFieldsForm } from './useAddressFieldsForm'
4
6
 
5
7
  export function AddressCity<
6
8
  TFieldValues extends FieldValues = FieldValues,
@@ -1,17 +1,14 @@
1
- import {
2
- SelectElement,
3
- FieldValues,
4
- FieldPath,
5
- useWatch,
6
- TextFieldElement,
7
- } from '@graphcommerce/ecommerce-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { SelectElement, TextFieldElement, useWatch } from '@graphcommerce/ecommerce-ui'
8
3
  import { useQuery } from '@graphcommerce/graphql'
9
4
  import { CountryRegionsDocument } from '@graphcommerce/magento-store'
10
- import { FormRow, filterNonNullableKeys } from '@graphcommerce/next-ui'
5
+ import { filterNonNullableKeys, FormRow } from '@graphcommerce/next-ui'
11
6
  import { Trans } from '@lingui/react'
12
7
  import { useMemo } from 'react'
13
- import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
8
+ import type { AddressFieldsOptions } from './useAddressFieldsForm'
9
+ import { useAddressFieldsForm } from './useAddressFieldsForm'
14
10
 
11
+ /** @public */
15
12
  export function useAddressCountryRegion<
16
13
  TFieldValues extends FieldValues = FieldValues,
17
14
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
@@ -1,4 +1,4 @@
1
- import { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
2
  import { FormRow } from '@graphcommerce/next-ui'
3
3
  import { AddressAddition } from './AddressAddition'
4
4
  import { AddressCity } from './AddressCity'
@@ -6,7 +6,7 @@ import { AddressCountryRegion } from './AddressCountryRegion'
6
6
  import { AddressHousenumber } from './AddressHouseNumber'
7
7
  import { AddressPostcode } from './AddressPostcode'
8
8
  import { AddressStreet } from './AddressStreet'
9
- import { AddressFieldsOptions } from './useAddressFieldsForm'
9
+ import type { AddressFieldsOptions } from './useAddressFieldsForm'
10
10
 
11
11
  export type AddressFieldsProps<
12
12
  TFieldValues extends FieldValues = FieldValues,
@@ -1,12 +1,9 @@
1
- import {
2
- TextFieldElement,
3
- FieldValues,
4
- FieldPath,
5
- houseNumberPattern,
6
- } from '@graphcommerce/ecommerce-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { TextFieldElement, houseNumberPattern } from '@graphcommerce/ecommerce-ui'
7
3
  import { i18n } from '@lingui/core'
8
4
  import { Trans } from '@lingui/react'
9
- import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
5
+ import type { AddressFieldsOptions } from './useAddressFieldsForm'
6
+ import { useAddressFieldsForm } from './useAddressFieldsForm'
10
7
 
11
8
  export function AddressHousenumber<
12
9
  TFieldValues extends FieldValues = FieldValues,
@@ -1,6 +1,8 @@
1
- import { FieldPath, FieldValues, TextFieldElement } from '@graphcommerce/ecommerce-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
3
  import { Trans } from '@lingui/macro'
3
- import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
4
+ import type { AddressFieldsOptions } from './useAddressFieldsForm'
5
+ import { useAddressFieldsForm } from './useAddressFieldsForm'
4
6
 
5
7
  export function AddressPostcode<
6
8
  TFieldValues extends FieldValues = FieldValues,
@@ -1,7 +1,8 @@
1
1
  import { TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
- import { FieldValues, FieldPath } from '@graphcommerce/react-hook-form'
2
+ import type { FieldPath, FieldValues } from '@graphcommerce/react-hook-form'
3
3
  import { Trans } from '@lingui/react'
4
- import { AddressFieldsOptions, useAddressFieldsForm } from './useAddressFieldsForm'
4
+ import type { AddressFieldsOptions } from './useAddressFieldsForm'
5
+ import { useAddressFieldsForm } from './useAddressFieldsForm'
5
6
 
6
7
  export function AddressStreet<
7
8
  TFieldValues extends FieldValues = FieldValues,
@@ -1,9 +1,5 @@
1
- import {
2
- FieldValues,
3
- FieldPath,
4
- UseFormReturn,
5
- assertFormGqlOperation,
6
- } from '@graphcommerce/react-hook-form'
1
+ import type { FieldPath, FieldValues, UseFormReturn } from '@graphcommerce/react-hook-form'
2
+ import { assertFormGqlOperation } from '@graphcommerce/react-hook-form'
7
3
 
8
4
  export type AddressFieldsOptions<
9
5
  TFieldValues extends FieldValues = FieldValues,
@@ -1,7 +1,8 @@
1
1
  import { useFindCountry } from '@graphcommerce/magento-store'
2
2
  import { extendableComponent } from '@graphcommerce/next-ui'
3
- import { SxProps, Theme, Typography } from '@mui/material'
4
- import { CustomerAddressFragment } from '../CreateCustomerAddressForm/CustomerAddress.gql'
3
+ import type { SxProps, Theme } from '@mui/material'
4
+ import { Typography } from '@mui/material'
5
+ import type { CustomerAddressFragment } from '../CreateCustomerAddressForm/CustomerAddress.gql'
5
6
 
6
7
  // exports.getEuMembers = function()
7
8
  // {
@@ -12,7 +13,7 @@ import { CustomerAddressFragment } from '../CreateCustomerAddressForm/CustomerAd
12
13
  // return exports.getEuMembers().indexOf(code.toUpperCase()) != -1;
13
14
  // };
14
15
 
15
- type AddressMultiLineProps = CustomerAddressFragment & { sx?: SxProps<Theme> }
16
+ export type AddressMultiLineProps = CustomerAddressFragment & { sx?: SxProps<Theme> }
16
17
 
17
18
  const name = 'AddressMultiLine'
18
19
  const parts = ['root', 'title'] as const
@@ -1,5 +1,5 @@
1
1
  import { useFindCountry } from '@graphcommerce/magento-store'
2
- import { CustomerAddressFragment } from '../CreateCustomerAddressForm/CustomerAddress.gql'
2
+ import type { CustomerAddressFragment } from '../CreateCustomerAddressForm/CustomerAddress.gql'
3
3
 
4
4
  export function AddressSingleLine(props: CustomerAddressFragment) {
5
5
  const {
@@ -1,4 +1,5 @@
1
- import { ApolloErrorAlert, ApolloErrorAlertProps } from '@graphcommerce/ecommerce-ui'
1
+ import type { ApolloErrorAlertProps } from '@graphcommerce/ecommerce-ui'
2
+ import { ApolloErrorAlert } from '@graphcommerce/ecommerce-ui'
2
3
  import { Button } from '@graphcommerce/next-ui'
3
4
  import { Trans } from '@lingui/react'
4
5
  import { useAuthorizationErrorMasked } from './useAuthorizationErrorMasked'
@@ -1,5 +1,6 @@
1
- import { ApolloErrorFullPage, ApolloErrorFullPageProps } from '@graphcommerce/ecommerce-ui'
2
- import { iconPerson, IconSvg } from '@graphcommerce/next-ui'
1
+ import type { ApolloErrorFullPageProps } from '@graphcommerce/ecommerce-ui'
2
+ import { ApolloErrorFullPage } from '@graphcommerce/ecommerce-ui'
3
+ import { IconSvg, iconPerson } from '@graphcommerce/next-ui'
3
4
  import { Trans } from '@lingui/react'
4
5
  import { Button } from '@mui/material'
5
6
  import type { SetOptional } from 'type-fest'
@@ -1,4 +1,5 @@
1
- import { ApolloErrorSnackbar, ApolloErrorSnackbarProps } from '@graphcommerce/ecommerce-ui'
1
+ import type { ApolloErrorSnackbarProps } from '@graphcommerce/ecommerce-ui'
2
+ import { ApolloErrorSnackbar } from '@graphcommerce/ecommerce-ui'
2
3
  import { Trans } from '@lingui/react'
3
4
  import { Button } from '@mui/material'
4
5
  import { useCustomerSession } from '../../hooks/useCustomerSession'
@@ -1,4 +1,4 @@
1
- import { ApolloError } from '@graphcommerce/graphql'
1
+ import type { ApolloError } from '@graphcommerce/graphql'
2
2
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
3
3
  import { i18n } from '@lingui/core'
4
4
  import { useCustomerSession } from '../../hooks/useCustomerSession'
@@ -1,46 +1,39 @@
1
1
  import { ApolloErrorSnackbar, CheckboxElement, SelectElement } from '@graphcommerce/ecommerce-ui'
2
+ import { useQuery } from '@graphcommerce/graphql'
3
+ import { StoreConfigDocument } from '@graphcommerce/magento-store'
2
4
  import {
3
- breakpointVal,
4
5
  Button,
5
- filterNonNullableKeys,
6
6
  FormRow,
7
- iconChevronDown,
8
7
  IconSvg,
8
+ breakpointVal,
9
+ filterNonNullableKeys,
10
+ iconChevronDown,
9
11
  } from '@graphcommerce/next-ui'
10
12
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
11
13
  import { Trans } from '@lingui/macro'
12
- import {
13
- Accordion,
14
- AccordionDetails,
15
- AccordionProps,
16
- AccordionSummary,
17
- Alert,
18
- Box,
19
- } from '@mui/material'
20
- import {
21
- CancelOrderDocument,
22
- CancelOrderMutation,
23
- CancelOrderMutationVariables,
24
- } from './CancelOrder.gql'
25
- import { OrderDetailsFragment } from '../OrderDetails/OrderDetails.gql'
26
- import { useQuery } from '@graphcommerce/graphql'
27
- import { StoreConfigDocument } from '@graphcommerce/magento-store'
14
+ import type { AccordionProps } from '@mui/material'
15
+ import { Accordion, AccordionDetails, AccordionSummary, Alert, Box } from '@mui/material'
28
16
  import { canCancelOrder } from '../../utils'
17
+ import type { OrderDetailsFragment } from '../OrderDetails/OrderDetails.gql'
18
+ import type { CancelOrderMutation, CancelOrderMutationVariables } from './CancelOrder.gql'
19
+ import { CancelOrderDocument } from './CancelOrder.gql'
29
20
 
30
- type CancelOrderFormProps = {
21
+ export type CancelOrderFormProps = {
31
22
  order: OrderDetailsFragment
32
23
  } & Omit<AccordionProps, 'children'>
33
24
 
34
25
  export function CancelOrderForm(props: CancelOrderFormProps) {
35
26
  const { order, sx, ...rest } = props
36
- const { id: orderId, number: orderNumber } = order
27
+ const { id: orderId } = order
37
28
 
38
29
  const form = useFormGqlMutation<
39
30
  CancelOrderMutation,
40
31
  CancelOrderMutationVariables & { confirm: boolean }
41
32
  >(CancelOrderDocument, { defaultValues: { orderId: atob(orderId) } })
42
33
 
43
- const options = useQuery(StoreConfigDocument).data?.storeConfig?.order_cancellation_reasons
34
+ const config = useQuery(StoreConfigDocument).data?.storeConfig
35
+ const options = config?.order_cancellation_reasons
36
+ const enabled = config?.order_cancellation_enabled
44
37
 
45
38
  const { control, formState, required, handleSubmit, error, data: cancelOrderData } = form
46
39
 
@@ -49,7 +42,7 @@ export function CancelOrderForm(props: CancelOrderFormProps) {
49
42
  const submittedWithoutErrors =
50
43
  formState.isSubmitSuccessful && !error && !cancelOrderData?.cancelOrder?.error
51
44
 
52
- const visible = canCancelOrder(order) || submittedWithoutErrors
45
+ const visible = enabled && (canCancelOrder(order) || submittedWithoutErrors)
53
46
 
54
47
  if (!visible) return null
55
48
 
@@ -1,11 +1,11 @@
1
- import { Form, FormActions, FormDivider, MessageSnackbar, Button } from '@graphcommerce/next-ui'
1
+ import { Button, Form, FormActions, FormDivider, MessageSnackbar } from '@graphcommerce/next-ui'
2
2
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
3
3
  import { Trans } from '@lingui/react'
4
4
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
5
5
  import { NameFields } from '../NameFields/NameFields'
6
6
  import { UpdateCustomerNameDocument } from './UpdateCustomerName.gql'
7
7
 
8
- type ChangeNameFormProps = {
8
+ export type ChangeNameFormProps = {
9
9
  prefix?: string
10
10
  firstname: string
11
11
  lastname: string
@@ -5,21 +5,18 @@ import {
5
5
  } from '@graphcommerce/ecommerce-ui'
6
6
  import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
7
7
  import {
8
+ Button,
8
9
  Form,
9
10
  FormActions,
11
+ FormDivider,
10
12
  FormRow,
11
13
  MessageSnackbar,
12
- FormDivider,
13
- Button,
14
14
  } from '@graphcommerce/next-ui'
15
15
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
16
16
  import { Trans } from '@lingui/react'
17
17
  import { ValidatedPasswordElement } from '../ValidatedPasswordElement/ValidatedPasswordElement'
18
- import {
19
- ChangePasswordDocument,
20
- ChangePasswordMutation,
21
- ChangePasswordMutationVariables,
22
- } from './ChangePassword.gql'
18
+ import type { ChangePasswordMutation, ChangePasswordMutationVariables } from './ChangePassword.gql'
19
+ import { ChangePasswordDocument } from './ChangePassword.gql'
23
20
 
24
21
  export function ChangePasswordForm() {
25
22
  const form = useFormGqlMutation<
@@ -1,9 +1,12 @@
1
- import { ActionCardListForm, FieldPath, FieldValues, useWatch } from '@graphcommerce/ecommerce-ui'
2
- import { ActionCard, ActionCardProps, FormRow, useStorefrontConfig } from '@graphcommerce/next-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { ActionCardListForm, useWatch } from '@graphcommerce/ecommerce-ui'
3
+ import type { ActionCardProps } from '@graphcommerce/next-ui'
4
+ import { ActionCard, FormRow, useStorefrontConfig } from '@graphcommerce/next-ui'
3
5
  import { t } from '@lingui/macro'
4
6
  import { CompanyName } from './CompanyName'
5
7
  import { CompanyVAT } from './CompanyVAT'
6
- import { CompanyFieldsOptions, useCompanyFieldsForm } from './useCompanyFieldsForm'
8
+ import type { CompanyFieldsOptions } from './useCompanyFieldsForm'
9
+ import { useCompanyFieldsForm } from './useCompanyFieldsForm'
7
10
 
8
11
  export type CompanyFieldsProps<
9
12
  TFieldValues extends FieldValues = FieldValues,
@@ -1,6 +1,8 @@
1
- import { TextFieldElement, FieldValues, FieldPath } from '@graphcommerce/ecommerce-ui'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { TextFieldElement } from '@graphcommerce/ecommerce-ui'
2
3
  import { Trans } from '@lingui/react'
3
- import { CompanyFieldsOptions, useCompanyFieldsForm } from './useCompanyFieldsForm'
4
+ import type { CompanyFieldsOptions } from './useCompanyFieldsForm'
5
+ import { useCompanyFieldsForm } from './useCompanyFieldsForm'
4
6
 
5
7
  export function CompanyName<
6
8
  TFieldValues extends FieldValues = FieldValues,
@@ -1,7 +1,9 @@
1
- import { TextFieldElement, FieldValues, FieldPath, useWatch } from '@graphcommerce/ecommerce-ui'
2
- import { CountryCodeEnum } from '@graphcommerce/graphql-mesh'
1
+ import type { FieldPath, FieldValues } from '@graphcommerce/ecommerce-ui'
2
+ import { TextFieldElement, useWatch } from '@graphcommerce/ecommerce-ui'
3
+ import type { CountryCodeEnum } from '@graphcommerce/graphql-mesh'
3
4
  import { Trans } from '@lingui/react'
4
- import { CompanyFieldsOptions, useCompanyFieldsForm } from './useCompanyFieldsForm'
5
+ import type { CompanyFieldsOptions } from './useCompanyFieldsForm'
6
+ import { useCompanyFieldsForm } from './useCompanyFieldsForm'
5
7
 
6
8
  export function CompanyVAT<
7
9
  TFieldValues extends FieldValues = FieldValues,
@@ -1,9 +1,5 @@
1
- import {
2
- FieldValues,
3
- FieldPath,
4
- UseFormReturn,
5
- assertFormGqlOperation,
6
- } from '@graphcommerce/react-hook-form'
1
+ import type { FieldPath, FieldValues, UseFormReturn } from '@graphcommerce/react-hook-form'
2
+ import { assertFormGqlOperation } from '@graphcommerce/react-hook-form'
7
3
 
8
4
  export type CompanyFieldsOptions<
9
5
  TFieldValues extends FieldValues = FieldValues,
@@ -1,20 +1,7 @@
1
- import {
2
- EmailElement,
3
- TextFieldElement,
4
- emailPattern,
5
- useFormGqlMutation,
6
- } from '@graphcommerce/ecommerce-ui'
7
- import {
8
- FormActions,
9
- FormRow,
10
- LayoutTitle,
11
- Button,
12
- FullPageMessage,
13
- IconSvg,
14
- iconPerson,
15
- } from '@graphcommerce/next-ui'
1
+ import { EmailElement, useFormGqlMutation } from '@graphcommerce/ecommerce-ui'
2
+ import { Button, FormRow, LayoutTitle, iconPerson } from '@graphcommerce/next-ui'
16
3
  import { Trans } from '@lingui/react'
17
- import { Alert, Box, Container, Divider, FormControl, Typography } from '@mui/material'
4
+ import { Alert, Box, Typography } from '@mui/material'
18
5
  import { useRouter } from 'next/router'
19
6
  import { ApolloCustomerErrorAlert } from '../ApolloCustomerError'
20
7
  import { ConfirmCustomerDocument } from './ConfirmCustomer.gql'
@@ -7,7 +7,8 @@ import {
7
7
  import { Button, Form, FormRow, MessageSnackbar } from '@graphcommerce/next-ui'
8
8
  import { FormPersist, useFormGqlMutation } from '@graphcommerce/react-hook-form'
9
9
  import { Trans } from '@lingui/macro'
10
- import { CustomerDocument, CustomerQuery, useCustomerQuery } from '../../hooks'
10
+ import type { CustomerQuery } from '../../hooks'
11
+ import { CustomerDocument, useCustomerQuery } from '../../hooks'
11
12
  import { ContactUsDocument } from './ContactUsMutation.gql'
12
13
 
13
14
  function findTelephone(data: CustomerQuery): string | undefined {
@@ -1,8 +1,8 @@
1
1
  import { ApolloErrorSnackbar, TelephoneElement } from '@graphcommerce/ecommerce-ui'
2
2
  import { useQuery } from '@graphcommerce/graphql'
3
- import { CountryCodeEnum } from '@graphcommerce/graphql-mesh'
3
+ import type { CountryCodeEnum } from '@graphcommerce/graphql-mesh'
4
4
  import { CountryRegionsDocument, StoreConfigDocument } from '@graphcommerce/magento-store'
5
- import { Form, FormActions, FormRow, Button, MessageSnackbar } from '@graphcommerce/next-ui'
5
+ import { Button, Form, FormActions, FormRow, MessageSnackbar } from '@graphcommerce/next-ui'
6
6
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
7
7
  import { Trans } from '@lingui/react'
8
8
  import { useRouter } from 'next/router'