Skip to content

Commit

Permalink
feature(unlock-app): Close login modal (#15069)
Browse files Browse the repository at this point in the history
* dispatch custom event

* trigger modal closure

* use existing custom event
  • Loading branch information
0xTxbi authored Nov 13, 2024
1 parent 50c3952 commit c90cd1a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions unlock-app/src/components/interface/connect/ConnectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
import { useConnectModal } from '~/hooks/useConnectModal'
import { Modal } from '@unlock-protocol/ui'
import { LoginModal } from '@privy-io/react-auth'
import { useEffect } from 'react'

export const ConnectModal = () => {
const { closeConnectModal, open } = useConnectModal()

useEffect(() => {
const handleLoginComplete = () => {
closeConnectModal()
}

window.addEventListener('locksmith.authenticated', handleLoginComplete)
return () => {
window.removeEventListener('locksmith.authenticated', handleLoginComplete)
}
}, [closeConnectModal])

return (
<Modal isOpen={open} setIsOpen={closeConnectModal} size="small">
<div className="z-10 w-full max-w-sm bg-white rounded-2xl">
Expand Down

0 comments on commit c90cd1a

Please sign in to comment.