Skip to content

Commit

Permalink
Merge pull request #2166 from graphcommerce-org/feature/GCOM-1318
Browse files Browse the repository at this point in the history
feat(GCOM-1318): dismiss login page and go back to previous page asap when logging in
  • Loading branch information
paales authored Jan 15, 2024
2 parents 88a5189 + 967dcdd commit 1dcf8e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
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

1 comment on commit 1dcf8e7

@vercel
Copy link

@vercel vercel bot commented on 1dcf8e7 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

graphcommerce-hygraph-dynamic-rows-ui – ./packages/hygraph-dynamic-rows-ui

graphcommerce-hygraph-dynamic-rows-ui.vercel.app
graphcommerce-hygraph-dynamic-rows-ui-graphcommerce.vercel.app
graphcommerce-hygraph-dynamic-rows-ui-git-canary-graphcommerce.vercel.app

Please sign in to comment.