From 304b81659caf82d9f500401d21da4110dd40db61 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 15 Jan 2024 16:37:15 +0100 Subject: [PATCH 1/4] Dismiss login page and go back to previous page asap when logging in --- .changeset/rotten-lions-chew.md | 5 +++++ .../magento-customer/hooks/useAccountSignInUpForm.tsx | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 .changeset/rotten-lions-chew.md diff --git a/.changeset/rotten-lions-chew.md b/.changeset/rotten-lions-chew.md new file mode 100644 index 0000000000..7f013398c9 --- /dev/null +++ b/.changeset/rotten-lions-chew.md @@ -0,0 +1,5 @@ +--- +"@graphcommerce/magento-customer": patch +--- + +feat(GCOM-1318): dismiss login page and go back to previous page asap when logging in diff --git a/packages/magento-customer/hooks/useAccountSignInUpForm.tsx b/packages/magento-customer/hooks/useAccountSignInUpForm.tsx index 41907a8577..a27dd62523 100644 --- a/packages/magento-customer/hooks/useAccountSignInUpForm.tsx +++ b/packages/magento-customer/hooks/useAccountSignInUpForm.tsx @@ -9,6 +9,8 @@ import { IsEmailAvailableQueryVariables, } from './IsEmailAvailable.gql' import { useCustomerSession } from './useCustomerSession' +import { useGo, usePageContext } from '@graphcommerce/framer-next-pages' +import { useShowBack } from '@graphcommerce/next-ui/Layout/components/LayoutHeaderBack' export type UseFormIsEmailAvailableProps = { onSubmitted?: (data: { email: string }) => void @@ -73,5 +75,11 @@ export function useAccountSignInUpForm(props: UseFormIsEmailAvailableProps = {}) if (isValid && isSubmitSuccessful) mode = hasAccount ? 'signin' : 'signup' } + const { closeSteps = 0 } = usePageContext() ?? {} + useEffect(() => { + // Automatically close the overlay if the user is signed in + if (mode === 'signedin' && closeSteps > 0) window.history.go(closeSteps * -1) + }, [mode, closeSteps]) + return { mode, form, submit } } From 710114a5bebcf2b7629d1bbf118a912c125cd2a5 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 15 Jan 2024 16:38:14 +0100 Subject: [PATCH 2/4] Cleanup --- packages/magento-customer/hooks/useAccountSignInUpForm.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/magento-customer/hooks/useAccountSignInUpForm.tsx b/packages/magento-customer/hooks/useAccountSignInUpForm.tsx index a27dd62523..cedef10e84 100644 --- a/packages/magento-customer/hooks/useAccountSignInUpForm.tsx +++ b/packages/magento-customer/hooks/useAccountSignInUpForm.tsx @@ -1,3 +1,4 @@ +import { usePageContext } from '@graphcommerce/framer-next-pages' import { useQuery } from '@graphcommerce/graphql' import { useFormGqlQuery } from '@graphcommerce/react-hook-form' import { useRouter } from 'next/router' @@ -9,8 +10,6 @@ import { IsEmailAvailableQueryVariables, } from './IsEmailAvailable.gql' import { useCustomerSession } from './useCustomerSession' -import { useGo, usePageContext } from '@graphcommerce/framer-next-pages' -import { useShowBack } from '@graphcommerce/next-ui/Layout/components/LayoutHeaderBack' export type UseFormIsEmailAvailableProps = { onSubmitted?: (data: { email: string }) => void From bd7eaaffaa8c3592bfe742d8f0a669a613a81d36 Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 15 Jan 2024 16:40:06 +0100 Subject: [PATCH 3/4] Missing dep --- packages/magento-customer/package.json | 1 + yarn.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/magento-customer/package.json b/packages/magento-customer/package.json index 09456dfc61..53f478cd6c 100644 --- a/packages/magento-customer/package.json +++ b/packages/magento-customer/package.json @@ -14,6 +14,7 @@ "peerDependencies": { "@graphcommerce/ecommerce-ui": "^8.0.0-canary.87", "@graphcommerce/eslint-config-pwa": "^8.0.0-canary.87", + "@graphcommerce/framer-next-pages": "^8.0.0-canary.87", "@graphcommerce/framer-utils": "^8.0.0-canary.87", "@graphcommerce/graphql": "^8.0.0-canary.87", "@graphcommerce/graphql-mesh": "^8.0.0-canary.87", diff --git a/yarn.lock b/yarn.lock index e8650e3186..42d9436482 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3591,6 +3591,7 @@ __metadata: peerDependencies: "@graphcommerce/ecommerce-ui": ^8.0.0-canary.87 "@graphcommerce/eslint-config-pwa": ^8.0.0-canary.87 + "@graphcommerce/framer-next-pages": ^8.0.0-canary.87 "@graphcommerce/framer-utils": ^8.0.0-canary.87 "@graphcommerce/graphql": ^8.0.0-canary.87 "@graphcommerce/graphql-mesh": ^8.0.0-canary.87 From 967dcdda1b4732710d06a066ed6fc89e7e54f00b Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 15 Jan 2024 16:40:25 +0100 Subject: [PATCH 4/4] Cleanup changeset --- .changeset/rotten-lions-chew.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/rotten-lions-chew.md b/.changeset/rotten-lions-chew.md index 7f013398c9..df0e168353 100644 --- a/.changeset/rotten-lions-chew.md +++ b/.changeset/rotten-lions-chew.md @@ -1,5 +1,5 @@ --- -"@graphcommerce/magento-customer": patch +'@graphcommerce/magento-customer': patch --- -feat(GCOM-1318): dismiss login page and go back to previous page asap when logging in +Dismiss login page and go back to previous page asap when logging in