@graphcommerce/magento-customer 8.0.3-canary.0 → 8.0.3-canary.2
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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.0.3-canary.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`3fbf3da`](https://github.com/graphcommerce-org/graphcommerce/commit/3fbf3da8a67f2fbaa7fa974a37cbbf34613844e4) - Solve an issue where the user would be presented with the Session expired dialog when the user would be logging in during the checkout process.
|
|
8
|
+
([@paales](https://github.com/paales))
|
|
9
|
+
|
|
10
|
+
## 8.0.3-canary.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#2207](https://github.com/graphcommerce-org/graphcommerce/pull/2207) [`4d7594c`](https://github.com/graphcommerce-org/graphcommerce/commit/4d7594ca2174f74bfa9f66a464b77b3fd04f3560) - After changing the default shipping or billing address in the account section other address would not properly update
|
|
15
|
+
([@paales](https://github.com/paales))
|
|
16
|
+
|
|
3
17
|
## 8.0.3-canary.0
|
|
4
18
|
|
|
5
19
|
## 8.0.2
|
|
@@ -1,37 +1,17 @@
|
|
|
1
1
|
import { PasswordElement } from '@graphcommerce/ecommerce-ui'
|
|
2
|
-
import { useApolloClient } from '@graphcommerce/graphql'
|
|
3
2
|
import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
|
|
4
3
|
import { Button, FormRow, FormActions } from '@graphcommerce/next-ui'
|
|
5
|
-
import { useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
6
4
|
import { Trans } from '@lingui/react'
|
|
7
5
|
import { Box, FormControl, Link, SxProps, Theme } from '@mui/material'
|
|
8
|
-
import {
|
|
6
|
+
import { useSignInForm } from '../../hooks/useSignInForm'
|
|
9
7
|
import { ApolloCustomerErrorAlert } from '../ApolloCustomerError/ApolloCustomerErrorAlert'
|
|
10
|
-
import { SignInDocument } from './SignIn.gql'
|
|
11
|
-
import { signOut } from '../SignOutForm/signOut'
|
|
12
8
|
|
|
13
9
|
export type SignInFormProps = { email: string; sx?: SxProps<Theme> }
|
|
14
10
|
|
|
15
11
|
export function SignInForm(props: SignInFormProps) {
|
|
16
12
|
const { email, sx } = props
|
|
17
|
-
const client = useApolloClient()
|
|
18
|
-
const form = useFormGqlMutation(
|
|
19
|
-
SignInDocument,
|
|
20
|
-
{
|
|
21
|
-
defaultValues: { email },
|
|
22
|
-
onBeforeSubmit: async (values) => {
|
|
23
|
-
const oldEmail = client.cache.readQuery({ query: CustomerDocument })?.customer?.email
|
|
24
13
|
|
|
25
|
-
|
|
26
|
-
* We are logging in because the session expired, but we're logging in with a different
|
|
27
|
-
* email address, we need to reset the store.
|
|
28
|
-
*/
|
|
29
|
-
if (oldEmail && oldEmail !== email) signOut(client)
|
|
30
|
-
return { ...values, email }
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
{ errorPolicy: 'all' },
|
|
34
|
-
)
|
|
14
|
+
const form = useSignInForm({ email })
|
|
35
15
|
|
|
36
16
|
const { handleSubmit, required, formState, error, control } = form
|
|
37
17
|
const [remainingError, authError] = graphqlErrorByCategory({
|
|
@@ -26,7 +26,7 @@ export function UpdateDefaultAddressForm(props: UpdateDefaultAddressFormProps) {
|
|
|
26
26
|
const form = useFormGqlMutation(
|
|
27
27
|
UpdateDefaultAddressDocument,
|
|
28
28
|
{ mode: 'onChange', defaultValues },
|
|
29
|
-
{ errorPolicy: 'all' },
|
|
29
|
+
{ errorPolicy: 'all', refetchQueries: ['AccountDashboardAddresses'] },
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
const { handleSubmit, control, error, reset, formState } = form
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useApolloClient } from '@graphcommerce/graphql'
|
|
2
|
+
import { UseFormGraphQlOptions, useFormGqlMutation } from '@graphcommerce/react-hook-form'
|
|
3
|
+
import {
|
|
4
|
+
SignInDocument,
|
|
5
|
+
SignInMutation,
|
|
6
|
+
SignInMutationVariables,
|
|
7
|
+
} from '../components/SignInForm/SignIn.gql'
|
|
8
|
+
import { signOut } from '../components/SignOutForm/signOut'
|
|
9
|
+
import { CustomerDocument } from './Customer.gql'
|
|
10
|
+
|
|
11
|
+
type UseSignInFormProps = {
|
|
12
|
+
email: string
|
|
13
|
+
} & UseFormGraphQlOptions<SignInMutation, SignInMutationVariables>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* To extend the actions that happen after a successful sign in, you can use the `onComplete` option.
|
|
17
|
+
*
|
|
18
|
+
* @example @graphcommerce/magento-cart/plugins/useSignInFormMergeCart
|
|
19
|
+
*/
|
|
20
|
+
export function useSignInForm({ email, ...options }: UseSignInFormProps) {
|
|
21
|
+
const client = useApolloClient()
|
|
22
|
+
|
|
23
|
+
return useFormGqlMutation(
|
|
24
|
+
SignInDocument,
|
|
25
|
+
{
|
|
26
|
+
...options,
|
|
27
|
+
defaultValues: { email, ...options?.defaultValues },
|
|
28
|
+
onBeforeSubmit: async (values) => {
|
|
29
|
+
const oldEmail = client.cache.readQuery({ query: CustomerDocument })?.customer?.email
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* We are logging in because the session expired, but we're logging in with a different
|
|
33
|
+
* email address, we need to reset the store.
|
|
34
|
+
*/
|
|
35
|
+
if (oldEmail && oldEmail !== email) signOut(client)
|
|
36
|
+
|
|
37
|
+
return options?.onBeforeSubmit
|
|
38
|
+
? options.onBeforeSubmit({ ...values, email })
|
|
39
|
+
: { ...values, email }
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{ errorPolicy: 'all' },
|
|
43
|
+
)
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-customer",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "8.0.3-canary.
|
|
5
|
+
"version": "8.0.3-canary.2",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/ecommerce-ui": "^8.0.3-canary.
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^8.0.3-canary.
|
|
17
|
-
"@graphcommerce/framer-next-pages": "^8.0.3-canary.
|
|
18
|
-
"@graphcommerce/framer-utils": "^8.0.3-canary.
|
|
19
|
-
"@graphcommerce/graphql": "^8.0.3-canary.
|
|
20
|
-
"@graphcommerce/graphql-mesh": "^8.0.3-canary.
|
|
21
|
-
"@graphcommerce/image": "^8.0.3-canary.
|
|
22
|
-
"@graphcommerce/magento-graphql": "^8.0.3-canary.
|
|
23
|
-
"@graphcommerce/magento-store": "^8.0.3-canary.
|
|
24
|
-
"@graphcommerce/next-ui": "^8.0.3-canary.
|
|
25
|
-
"@graphcommerce/prettier-config-pwa": "^8.0.3-canary.
|
|
26
|
-
"@graphcommerce/react-hook-form": "^8.0.3-canary.
|
|
27
|
-
"@graphcommerce/typescript-config-pwa": "^8.0.3-canary.
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^8.0.3-canary.2",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^8.0.3-canary.2",
|
|
17
|
+
"@graphcommerce/framer-next-pages": "^8.0.3-canary.2",
|
|
18
|
+
"@graphcommerce/framer-utils": "^8.0.3-canary.2",
|
|
19
|
+
"@graphcommerce/graphql": "^8.0.3-canary.2",
|
|
20
|
+
"@graphcommerce/graphql-mesh": "^8.0.3-canary.2",
|
|
21
|
+
"@graphcommerce/image": "^8.0.3-canary.2",
|
|
22
|
+
"@graphcommerce/magento-graphql": "^8.0.3-canary.2",
|
|
23
|
+
"@graphcommerce/magento-store": "^8.0.3-canary.2",
|
|
24
|
+
"@graphcommerce/next-ui": "^8.0.3-canary.2",
|
|
25
|
+
"@graphcommerce/prettier-config-pwa": "^8.0.3-canary.2",
|
|
26
|
+
"@graphcommerce/react-hook-form": "^8.0.3-canary.2",
|
|
27
|
+
"@graphcommerce/typescript-config-pwa": "^8.0.3-canary.2",
|
|
28
28
|
"@lingui/core": "^4.2.1",
|
|
29
29
|
"@lingui/macro": "^4.2.1",
|
|
30
30
|
"@lingui/react": "^4.2.1",
|