Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(GCOM-1318): dismiss login page and go back to previous page asap when logging in #2166

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-lions-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-customer': patch
---

Dismiss login page and go back to previous page asap when logging in
7 changes: 7 additions & 0 deletions packages/magento-customer/hooks/useAccountSignInUpForm.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -73,5 +74,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 }
}
1 change: 1 addition & 0 deletions packages/magento-customer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading