@graphcommerce/magento-customer 3.6.44 → 4.1.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 (29) hide show
  1. package/CHANGELOG.md +404 -258
  2. package/components/AccountAddress/index.tsx +38 -42
  3. package/components/AccountAddresses/index.tsx +46 -41
  4. package/components/AddressFields/index.tsx +2 -2
  5. package/components/AddressMultiLine/index.tsx +8 -6
  6. package/components/ApolloCustomerError/ApolloCustomerErrorAlert.tsx +2 -2
  7. package/components/ApolloCustomerError/ApolloCustomerErrorFullPage.tsx +3 -5
  8. package/components/ChangeNameForm/index.tsx +1 -2
  9. package/components/ChangePasswordForm/ChangePasswordForm.tsx +2 -4
  10. package/components/CreateCustomerAddressForm/index.tsx +3 -4
  11. package/components/CustomerFab/index.tsx +21 -16
  12. package/components/CustomerMenuFabItem/index.tsx +12 -28
  13. package/components/DeleteCustomerAddressForm/index.tsx +1 -1
  14. package/components/EditAddressForm/index.tsx +6 -17
  15. package/components/ForgotPasswordForm/ForgotPasswordForm.tsx +12 -17
  16. package/components/NameFields/index.tsx +1 -1
  17. package/components/ResetPasswordForm/index.tsx +1 -1
  18. package/components/SignInForm/SignInForm.tsx +7 -21
  19. package/components/SignInForm/SignInFormInline.tsx +35 -29
  20. package/components/SignUpForm/SignUpForm.tsx +1 -2
  21. package/components/SignUpForm/SignUpFormInline.tsx +25 -35
  22. package/components/UpdateCustomerEmailForm/index.tsx +1 -2
  23. package/components/UpdateDefaultAddressForm/index.tsx +3 -8
  24. package/hooks/useExtractCustomerErrors.tsx +1 -1
  25. package/hooks/useFormIsEmailAvailable.tsx +1 -1
  26. package/index.ts +1 -3
  27. package/link/{createAuthLink.ts → createCustomerTokenLink.ts} +2 -3
  28. package/package.json +18 -24
  29. package/typePolicies.ts +1 -1
@@ -1,62 +1,58 @@
1
+ import { extendableComponent } from '@graphcommerce/next-ui'
1
2
  import { Trans } from '@lingui/macro'
2
- import { Link, makeStyles, Theme } from '@material-ui/core'
3
+ import { Box, Link, SxProps, Theme } from '@mui/material'
3
4
  import PageLink from 'next/link'
4
- import React from 'react'
5
5
  import AddressMultiLine from '../AddressMultiLine'
6
6
  import DeleteCustomerAddressForm from '../DeleteCustomerAddressForm'
7
7
  import UpdateDefaultAddressForm from '../UpdateDefaultAddressForm'
8
8
  import { AccountAddressFragment } from './AccountAddress.gql'
9
9
 
10
- export type AccountAddressProps = AccountAddressFragment
10
+ export type AccountAddressProps = AccountAddressFragment & { sx?: SxProps<Theme> }
11
11
 
12
- const useStyles = makeStyles(
13
- (theme: Theme) => ({
14
- root: {
15
- display: 'flex',
16
- justifyContent: 'space-between',
17
- paddingTop: theme.spacings.md,
18
- paddingBottom: theme.spacings.md,
19
- ...theme.typography.body2,
20
- },
21
- address: {
22
- '& > span': {
23
- display: 'block',
24
- },
25
- },
26
- switches: {
27
- paddingTop: theme.spacings.xxs,
28
- },
29
- actions: {
30
- display: 'flex',
31
- justifyContent: 'space-between',
32
- flexDirection: 'column',
33
- textAlign: 'right',
34
- },
35
- }),
36
- { name: 'AccountAddress' },
37
- )
12
+ const name = 'AccountAddress'
13
+ const parts = ['root', 'address', 'switches', 'actions'] as const
14
+ const { classes } = extendableComponent(name, parts)
38
15
 
39
16
  export default function AccountAddress(props: AccountAddressProps) {
40
- const { id } = props
41
- const classes = useStyles()
17
+ const { id, sx = [], ...addressProps } = props
42
18
 
43
19
  return (
44
- <div className={classes.root}>
45
- <div className={classes.address}>
46
- <AddressMultiLine {...props} />
20
+ <Box
21
+ className={classes.root}
22
+ sx={[
23
+ (theme) => ({
24
+ display: 'flex',
25
+ justifyContent: 'space-between',
26
+ paddingTop: theme.spacings.md,
27
+ paddingBottom: theme.spacings.md,
28
+ typography: 'body2',
29
+ }),
30
+ ...(Array.isArray(sx) ? sx : [sx]),
31
+ ]}
32
+ >
33
+ <Box className={classes.address} sx={{ '& > span': { display: 'block' } }}>
34
+ <AddressMultiLine id={id} {...addressProps} />
47
35
 
48
- <div className={classes.switches}>
49
- <UpdateDefaultAddressForm {...props} />
50
- </div>
51
- </div>
52
- <div className={classes.actions}>
36
+ <Box className={classes.switches} sx={(theme) => ({ paddingTop: theme.spacings.xxs })}>
37
+ <UpdateDefaultAddressForm id={id} {...addressProps} />
38
+ </Box>
39
+ </Box>
40
+ <Box
41
+ className={classes.actions}
42
+ sx={{
43
+ display: 'flex',
44
+ justifyContent: 'space-between',
45
+ flexDirection: 'column',
46
+ textAlign: 'right',
47
+ }}
48
+ >
53
49
  <PageLink href={`/account/addresses/edit?addressId=${id}`} passHref>
54
- <Link color='primary'>
50
+ <Link color='primary' underline='hover'>
55
51
  <Trans>Edit</Trans>
56
52
  </Link>
57
53
  </PageLink>
58
54
  <DeleteCustomerAddressForm addressId={id ?? undefined} />
59
- </div>
60
- </div>
55
+ </Box>
56
+ </Box>
61
57
  )
62
58
  }
@@ -1,59 +1,51 @@
1
1
  import {
2
- Button,
3
2
  FullPageMessage,
4
3
  SectionContainer,
5
- MessageSnackbar,
6
4
  iconHome,
7
- SvgImageSimple,
5
+ SvgIcon,
6
+ extendableComponent,
8
7
  } from '@graphcommerce/next-ui'
9
8
  import { Trans } from '@lingui/macro'
10
- import { makeStyles, Theme } from '@material-ui/core'
11
- import { Skeleton } from '@material-ui/lab'
9
+ import { Skeleton, Button, Box, Theme, SxProps } from '@mui/material'
12
10
  import Link from 'next/link'
13
- import { useRouter } from 'next/router'
14
- import React from 'react'
15
11
  import AccountAddress from '../AccountAddress'
16
12
  import { AccountAddressesFragment } from './AccountAddresses.gql'
17
13
 
18
- export type AccountAddressesProps = AccountAddressesFragment & { loading: boolean }
14
+ export type AccountAddressesProps = AccountAddressesFragment & {
15
+ loading: boolean
16
+ sx?: SxProps<Theme>
17
+ }
19
18
 
20
- const useStyles = makeStyles(
21
- (theme: Theme) => ({
22
- root: {
23
- '& > div': {
24
- borderBottom: `1px solid ${theme.palette.divider}`,
25
- },
26
- },
27
- sectionContainer: {
28
- position: 'absolute',
29
- },
30
- button: {
31
- display: 'block',
32
- maxWidth: 'max-content',
33
- margin: `${theme.spacings.md} auto`,
34
- padding: `${theme.spacings.xxs} ${theme.spacings.md}`,
35
- },
36
- link: {
37
- textDecoration: 'none',
38
- },
39
- }),
40
- { name: 'AccountAddresses' },
41
- )
19
+ const name = 'AccountAddresses' as const
20
+ const parts = ['root', 'addresses', 'button', 'link'] as const
21
+ const { classes } = extendableComponent(name, parts)
42
22
 
43
23
  export default function AccountAddresses(props: AccountAddressesProps) {
44
- const { addresses, loading } = props
45
- const classes = useStyles()
46
- const router = useRouter()
24
+ const { addresses, loading, sx = [] } = props
47
25
 
48
26
  if (loading) {
49
27
  return (
50
- <SectionContainer labelLeft='Shipping addresses'>
51
- <div className={classes.root}>
28
+ <SectionContainer labelLeft='Shipping addresses' sx={sx} className={classes.root}>
29
+ <Box
30
+ className={classes.addresses}
31
+ sx={(theme) => ({ '& > div': { borderBottom: `1px solid ${theme.palette.divider}` } })}
32
+ >
52
33
  <Skeleton height={128} />
53
34
  <Skeleton height={128} />
54
35
  <Skeleton height={128} />
55
- </div>
56
- <Button className={classes.button} variant='contained' color='primary' disabled>
36
+ </Box>
37
+ <Button
38
+ className={classes.button}
39
+ variant='contained'
40
+ color='primary'
41
+ disabled
42
+ size='large'
43
+ sx={(theme) => ({
44
+ display: 'block',
45
+ maxWidth: 'max-content',
46
+ margin: `${theme.spacings.md} auto`,
47
+ })}
48
+ >
57
49
  <Trans>Add new address</Trans>
58
50
  </Button>
59
51
  </SectionContainer>
@@ -65,7 +57,7 @@ export default function AccountAddresses(props: AccountAddressesProps) {
65
57
  {((addresses && addresses.length === 0) || !addresses) && (
66
58
  <FullPageMessage
67
59
  title={<Trans>You have no addresses saved yet</Trans>}
68
- icon={<SvgImageSimple src={iconHome} size='xxl' />}
60
+ icon={<SvgIcon src={iconHome} size='xxl' />}
69
61
  button={
70
62
  <Link href='/account/addresses/add' passHref>
71
63
  <Button size='large' variant='contained' color='primary'>
@@ -78,14 +70,27 @@ export default function AccountAddresses(props: AccountAddressesProps) {
78
70
 
79
71
  {addresses && addresses.length >= 1 && (
80
72
  <SectionContainer labelLeft='Shipping addresses'>
81
- <div className={classes.root}>
73
+ <Box
74
+ className={classes.addresses}
75
+ sx={(theme) => ({ '& > div': { borderBottom: `1px solid ${theme.palette.divider}` } })}
76
+ >
82
77
  {addresses?.map((address) => (
83
78
  <AccountAddress key={address?.id} {...address} />
84
79
  ))}
85
- </div>
80
+ </Box>
86
81
 
87
82
  <Link href='/account/addresses/add' passHref>
88
- <Button className={classes.button} variant='contained' color='primary'>
83
+ <Button
84
+ className={classes.button}
85
+ variant='contained'
86
+ color='primary'
87
+ size='large'
88
+ sx={(theme) => ({
89
+ display: 'block',
90
+ maxWidth: 'max-content',
91
+ margin: `${theme.spacings.md} auto`,
92
+ })}
93
+ >
89
94
  <Trans>Add new address</Trans>
90
95
  </Button>
91
96
  </Link>
@@ -1,4 +1,4 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@graphcommerce/graphql'
2
2
  import { CountryRegionsDocument } from '@graphcommerce/magento-store'
3
3
  import { FormRow, InputCheckmark } from '@graphcommerce/next-ui'
4
4
  import {
@@ -7,7 +7,7 @@ import {
7
7
  UseFormReturn,
8
8
  } from '@graphcommerce/react-hook-form'
9
9
  import { t, Trans } from '@lingui/macro'
10
- import { TextField } from '@material-ui/core'
10
+ import { TextField } from '@mui/material'
11
11
  import React, { useMemo } from 'react'
12
12
 
13
13
  type AddressFieldValues = {
@@ -1,6 +1,6 @@
1
1
  import { useFindCountry } from '@graphcommerce/magento-store'
2
- import { UseStyles } from '@graphcommerce/next-ui'
3
- import { makeStyles, Typography } from '@material-ui/core'
2
+ import { extendableComponent } from '@graphcommerce/next-ui'
3
+ import { SxProps, Theme, Typography } from '@mui/material'
4
4
  import { CustomerAddressFragment } from '../CreateCustomerAddressForm/CustomerAddress.gql'
5
5
 
6
6
  // exports.getEuMembers = function()
@@ -12,9 +12,11 @@ import { CustomerAddressFragment } from '../CreateCustomerAddressForm/CustomerAd
12
12
  // return exports.getEuMembers().indexOf(code.toUpperCase()) != -1;
13
13
  // };
14
14
 
15
- const useStyles = makeStyles({ title: {} }, { name: 'AddressMultiLine' })
15
+ type AddressMultiLineProps = CustomerAddressFragment & { sx?: SxProps<Theme> }
16
16
 
17
- type AddressMultiLineProps = CustomerAddressFragment & UseStyles<typeof useStyles>
17
+ const name = 'AddressMultiLine'
18
+ const parts = ['root', 'title'] as const
19
+ const { classes } = extendableComponent(name, parts)
18
20
 
19
21
  export default function AddressMultiLine(props: AddressMultiLineProps) {
20
22
  const {
@@ -29,14 +31,14 @@ export default function AddressMultiLine(props: AddressMultiLineProps) {
29
31
  city,
30
32
  postcode,
31
33
  country_code,
34
+ sx = [],
32
35
  } = props
33
36
  const countryName = useFindCountry(country_code)?.full_name_locale ?? country_code
34
37
 
35
38
  const regionName = typeof region === 'string' ? region : region?.region
36
- const classes = useStyles(props)
37
39
 
38
40
  return (
39
- <Typography variant='body1' component='div'>
41
+ <Typography variant='body1' component='div' className={classes.root} sx={sx}>
40
42
  <div className={classes.title}>
41
43
  <div>{company}</div>
42
44
  <div>
@@ -1,6 +1,6 @@
1
1
  import { ApolloErrorAlert, ApolloErrorAlertProps } from '@graphcommerce/next-ui'
2
2
  import { Trans } from '@lingui/macro'
3
- import { Link } from '@material-ui/core'
3
+ import { Link } from '@mui/material'
4
4
  import NextLink from 'next/link'
5
5
  import React from 'react'
6
6
  import { useExtractCustomerErrors } from '../../hooks/useExtractCustomerErrors'
@@ -12,7 +12,7 @@ export default function ApolloCustomerErrorAlert(props: MagentoErrorAlertProps)
12
12
 
13
13
  const action = unauthorized && (
14
14
  <NextLink href='/account/signin' passHref>
15
- <Link>
15
+ <Link underline='hover'>
16
16
  <Trans>Create Account</Trans> / <Trans>Sign In</Trans>
17
17
  </Link>
18
18
  </NextLink>
@@ -1,14 +1,12 @@
1
1
  import {
2
2
  ApolloErrorFullPage,
3
3
  ApolloErrorAlertProps,
4
- Button,
5
4
  iconPerson,
6
- SvgImageSimple,
5
+ SvgIcon,
7
6
  } from '@graphcommerce/next-ui'
8
7
  import { Trans } from '@lingui/macro'
8
+ import { Button } from '@mui/material'
9
9
  import PageLink from 'next/link'
10
- import React from 'react'
11
-
12
10
  import { useExtractCustomerErrors } from '../../hooks/useExtractCustomerErrors'
13
11
 
14
12
  type ApolloCustomerErrorFullPageProps = {
@@ -23,7 +21,7 @@ export default function ApolloCustomerErrorFullPage(props: ApolloCustomerErrorFu
23
21
  return (
24
22
  <ApolloErrorFullPage
25
23
  error={error}
26
- icon={<SvgImageSimple src={iconPerson} size='xxl' />}
24
+ icon={<SvgIcon src={iconPerson} size='xxl' />}
27
25
  button={
28
26
  unauthorized ? (
29
27
  <PageLink href={signInHref} passHref>
@@ -1,7 +1,6 @@
1
- import { Button, Form, FormActions, FormDivider, MessageSnackbar } from '@graphcommerce/next-ui'
1
+ import { Form, FormActions, FormDivider, MessageSnackbar, Button } from '@graphcommerce/next-ui'
2
2
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
3
3
  import { Trans } from '@lingui/macro'
4
- import React from 'react'
5
4
  import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
6
5
  import NameFields from '../NameFields'
7
6
  import { UpdateCustomerNameDocument } from './UpdateCustomerName.gql'
@@ -1,16 +1,14 @@
1
1
  import {
2
- Button,
3
2
  Form,
4
3
  FormActions,
5
4
  FormRow,
6
5
  MessageSnackbar,
7
6
  FormDivider,
7
+ Button,
8
8
  } from '@graphcommerce/next-ui'
9
9
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
10
10
  import { Trans, t } from '@lingui/macro'
11
- import { TextField } from '@material-ui/core'
12
- import React from 'react'
13
-
11
+ import { TextField } from '@mui/material'
14
12
  import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
15
13
  import {
16
14
  ChangePasswordDocument,
@@ -1,18 +1,17 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@graphcommerce/graphql'
2
2
  import { CountryRegionsDocument } from '@graphcommerce/magento-store'
3
3
  import {
4
- Button,
5
4
  Form,
6
5
  FormActions,
7
6
  FormDivider,
8
7
  FormRow,
9
8
  InputCheckmark,
9
+ Button,
10
10
  } from '@graphcommerce/next-ui'
11
11
  import { phonePattern, useFormGqlMutation } from '@graphcommerce/react-hook-form'
12
12
  import { Trans, t } from '@lingui/macro'
13
- import { TextField } from '@material-ui/core'
13
+ import { TextField } from '@mui/material'
14
14
  import { useRouter } from 'next/router'
15
- import React from 'react'
16
15
  import AddressFields from '../AddressFields'
17
16
  import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
18
17
  import NameFields from '../NameFields'
@@ -1,27 +1,30 @@
1
- import { useQuery } from '@apollo/client'
2
- import { iconPerson, StyledBadge, SvgImageSimple, UseStyles } from '@graphcommerce/next-ui'
1
+ import { useQuery } from '@graphcommerce/graphql'
2
+ import {
3
+ iconPerson,
4
+ DesktopHeaderBadge,
5
+ SvgIcon,
6
+ extendableComponent,
7
+ } from '@graphcommerce/next-ui'
3
8
  import { t } from '@lingui/macro'
4
- import { Fab, FabProps as FabPropsType, makeStyles, NoSsr, Theme } from '@material-ui/core'
9
+ import { Fab, FabProps as FabPropsType, NoSsr, SxProps, Theme } from '@mui/material'
5
10
  import PageLink from 'next/link'
6
11
  import React from 'react'
7
12
  import { CustomerTokenDocument, CustomerTokenQuery } from '../../hooks'
8
13
 
9
- const useStyles = makeStyles((theme: Theme) => ({
10
- colorError: {
11
- backgroundColor: theme.palette.grey['500'],
12
- },
13
- }))
14
-
15
14
  type CustomerFabContentProps = CustomerTokenQuery & {
16
15
  icon?: React.ReactNode
17
16
  authHref: string
18
17
  guestHref: string
19
18
  FabProps?: Omit<FabPropsType, 'children'>
20
- } & UseStyles<typeof useStyles>
19
+ sx?: SxProps<Theme>
20
+ }
21
+
22
+ const name = 'CustomerFab'
23
+ const parts = ['root'] as const
24
+ const { classes } = extendableComponent(name, parts)
21
25
 
22
26
  function CustomerFabContent(props: CustomerFabContentProps) {
23
- const { customerToken, icon, guestHref, authHref, FabProps } = props
24
- const classes = useStyles(props)
27
+ const { customerToken, icon, guestHref, authHref, FabProps, sx } = props
25
28
  const requireAuth = Boolean(!customerToken || !customerToken.valid)
26
29
 
27
30
  return (
@@ -31,16 +34,18 @@ function CustomerFabContent(props: CustomerFabContentProps) {
31
34
  data-test-id='customer-fab'
32
35
  aria-label={t`Account`}
33
36
  size='large'
37
+ className={classes.root}
34
38
  {...FabProps}
39
+ sx={sx}
35
40
  >
36
- <StyledBadge
41
+ <DesktopHeaderBadge
37
42
  badgeContent={customerToken?.token ? 1 : 0}
38
43
  color={customerToken?.valid ? 'primary' : 'error'}
39
44
  variant='dot'
40
- classes={{ colorError: classes.colorError }}
45
+ overlap='circular'
41
46
  >
42
- {icon ?? <SvgImageSimple src={iconPerson} size='large' />}
43
- </StyledBadge>
47
+ {icon ?? <SvgIcon src={iconPerson} size='large' />}
48
+ </DesktopHeaderBadge>
44
49
  </Fab>
45
50
  </PageLink>
46
51
  )
@@ -1,54 +1,38 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@graphcommerce/graphql'
2
2
  import {
3
3
  MenuFabSecondaryItem,
4
- StyledBadge,
5
- UseStyles,
4
+ DesktopHeaderBadge,
6
5
  iconPerson,
7
- SvgImageSimple,
6
+ SvgIcon,
8
7
  } from '@graphcommerce/next-ui'
9
- import { makeStyles, NoSsr, Theme } from '@material-ui/core'
8
+ import { NoSsr, SxProps, Theme } from '@mui/material'
10
9
  import React from 'react'
11
10
  import { CustomerTokenDocument, CustomerTokenQuery } from '../../hooks'
12
11
 
13
- const useStyles = makeStyles((theme: Theme) => ({
14
- colorError: {
15
- backgroundColor: theme.palette.grey['500'],
16
- },
17
- badge: {
18
- top: 3,
19
- right: 3,
20
- padding: 3,
21
- [theme.breakpoints.up('md')]: {
22
- top: 5,
23
- right: 7,
24
- padding: 4,
25
- },
26
- },
27
- }))
28
-
29
12
  type CustomerMenuFabItemProps = CustomerTokenQuery & {
30
13
  icon?: React.ReactNode
31
14
  children: React.ReactNode
32
15
  authHref: string
33
16
  guestHref: string
34
- } & UseStyles<typeof useStyles>
17
+ sx?: SxProps<Theme>
18
+ }
35
19
 
36
20
  function CustomerMenuFabItemContent(props: CustomerMenuFabItemProps) {
37
- const { customerToken, icon, children, guestHref, authHref } = props
38
- const classes = useStyles(props)
21
+ const { customerToken, icon, children, guestHref, authHref, sx = [] } = props
39
22
  const requireAuth = Boolean(!customerToken || !customerToken.valid)
40
23
 
41
24
  return (
42
25
  <MenuFabSecondaryItem
26
+ sx={sx}
43
27
  icon={
44
- <StyledBadge
28
+ <DesktopHeaderBadge
45
29
  badgeContent={customerToken?.token ? 1 : 0}
46
30
  color={customerToken?.valid ? 'primary' : 'error'}
47
31
  variant='dot'
48
- classes={{ colorError: classes.colorError, badge: classes.badge }}
32
+ overlap='circular'
49
33
  >
50
- {icon ?? <SvgImageSimple src={iconPerson} />}
51
- </StyledBadge>
34
+ {icon ?? <SvgIcon src={iconPerson} size='medium' />}
35
+ </DesktopHeaderBadge>
52
36
  }
53
37
  href={requireAuth ? guestHref : authHref}
54
38
  >
@@ -1,7 +1,7 @@
1
1
  import { ApolloErrorSnackbar } from '@graphcommerce/next-ui'
2
2
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
3
3
  import { Trans } from '@lingui/macro'
4
- import { Button } from '@material-ui/core'
4
+ import { Button } from '@mui/material'
5
5
  import React from 'react'
6
6
  import { DeleteCustomerAddressFormDocument } from './DeleteCustomerAddressForm.gql'
7
7
 
@@ -1,4 +1,4 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@graphcommerce/graphql'
2
2
  import { CountryRegionsDocument } from '@graphcommerce/magento-store'
3
3
  import {
4
4
  Button,
@@ -10,30 +10,19 @@ import {
10
10
  } from '@graphcommerce/next-ui'
11
11
  import { phonePattern, useFormGqlMutation } from '@graphcommerce/react-hook-form'
12
12
  import { t, Trans } from '@lingui/macro'
13
- import { makeStyles, TextField } from '@material-ui/core'
13
+ import { SxProps, TextField, Theme } from '@mui/material'
14
14
  import { useRouter } from 'next/router'
15
- import React from 'react'
16
15
  import { AccountAddressFragment } from '../AccountAddress/AccountAddress.gql'
17
16
  import AddressFields from '../AddressFields'
18
17
  import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
19
18
  import NameFields from '../NameFields'
20
19
  import { UpdateCustomerAddressDocument } from './UpdateCustomerAddress.gql'
21
20
 
22
- const useStyles = makeStyles(
23
- () => ({
24
- editActions: {
25
- paddingBottom: 0,
26
- },
27
- }),
28
- { name: 'EditAddressForm' },
29
- )
30
-
31
- type EditAddressFormProps = { address?: AccountAddressFragment }
21
+ type EditAddressFormProps = { address?: AccountAddressFragment; sx?: SxProps<Theme> }
32
22
 
33
23
  export default function EditAddressForm(props: EditAddressFormProps) {
34
24
  const countries = useQuery(CountryRegionsDocument).data?.countries
35
- const { address } = props
36
- const classes = useStyles()
25
+ const { address, sx } = props
37
26
  const router = useRouter()
38
27
 
39
28
  const form = useFormGqlMutation(
@@ -85,7 +74,7 @@ export default function EditAddressForm(props: EditAddressFormProps) {
85
74
 
86
75
  return (
87
76
  <>
88
- <Form onSubmit={submitHandler} noValidate>
77
+ <Form onSubmit={submitHandler} noValidate sx={sx}>
89
78
  <NameFields form={form} prefix />
90
79
  <AddressFields form={form} />
91
80
 
@@ -108,7 +97,7 @@ export default function EditAddressForm(props: EditAddressFormProps) {
108
97
 
109
98
  <FormDivider />
110
99
 
111
- <FormActions classes={{ root: classes.editActions }}>
100
+ <FormActions sx={{ paddingBottom: 0 }}>
112
101
  <Button
113
102
  type='submit'
114
103
  variant='contained'
@@ -1,9 +1,7 @@
1
1
  import { Button, Form, FormActions, FormRow } from '@graphcommerce/next-ui'
2
2
  import { emailPattern, useFormGqlMutation } from '@graphcommerce/react-hook-form'
3
3
  import { t, Trans } from '@lingui/macro'
4
- import { makeStyles, TextField, Theme } from '@material-ui/core'
5
- import { Alert } from '@material-ui/lab'
6
- import React from 'react'
4
+ import { TextField, Alert, SxProps, Theme } from '@mui/material'
7
5
  import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'
8
6
  import {
9
7
  ForgotPasswordDocument,
@@ -11,18 +9,8 @@ import {
11
9
  ForgotPasswordMutationVariables,
12
10
  } from './ForgotPassword.gql'
13
11
 
14
- const useStyles = makeStyles(
15
- (theme: Theme) => ({
16
- alert: {
17
- marginTop: theme.spacings.md,
18
- marginBottom: theme.spacings.sm,
19
- },
20
- }),
21
- { name: 'ForgotPasswordForm' },
22
- )
23
-
24
- export default function ForgotPasswordForm() {
25
- const classes = useStyles()
12
+ export default function ForgotPasswordForm(props: { sx?: SxProps<Theme> }) {
13
+ const { sx = [] } = props
26
14
  const form = useFormGqlMutation<ForgotPasswordMutation, ForgotPasswordMutationVariables>(
27
15
  ForgotPasswordDocument,
28
16
  )
@@ -31,14 +19,21 @@ export default function ForgotPasswordForm() {
31
19
 
32
20
  if (formState.isSubmitSuccessful && data) {
33
21
  return (
34
- <Alert severity='success' variant='standard' className={classes.alert}>
22
+ <Alert
23
+ severity='success'
24
+ variant='standard'
25
+ sx={(theme) => ({
26
+ marginTop: theme.spacings.md,
27
+ marginBottom: theme.spacings.sm,
28
+ })}
29
+ >
35
30
  <Trans>We've send a password reset link to your email address!</Trans>
36
31
  </Alert>
37
32
  )
38
33
  }
39
34
 
40
35
  return (
41
- <Form onSubmit={submitHandler} noValidate>
36
+ <Form onSubmit={submitHandler} noValidate sx={sx}>
42
37
  <FormRow>
43
38
  <TextField
44
39
  variant='outlined'
@@ -1,7 +1,7 @@
1
1
  import { FormRow, InputCheckmark } from '@graphcommerce/next-ui'
2
2
  import { assertFormGqlOperation, Controller, UseFormReturn } from '@graphcommerce/react-hook-form'
3
3
  import { t, Trans } from '@lingui/macro'
4
- import { MenuItem, TextField } from '@material-ui/core'
4
+ import { MenuItem, TextField } from '@mui/material'
5
5
  import React from 'react'
6
6
 
7
7
  type NameFieldValues = {
@@ -1,7 +1,7 @@
1
1
  import { Button, Form, FormActions, FormRow } from '@graphcommerce/next-ui'
2
2
  import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
3
3
  import { Trans } from '@lingui/macro'
4
- import { TextField } from '@material-ui/core'
4
+ import { TextField } from '@mui/material'
5
5
  import { useRouter } from 'next/router'
6
6
  import React from 'react'
7
7
  import ApolloCustomerErrorAlert from '../ApolloCustomerError/ApolloCustomerErrorAlert'