-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
129 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/components/walletconnect/HeaderWidget/ErrorFalllback.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useRef } from 'react' | ||
import type { ReactElement } from 'react' | ||
|
||
import Popup from '../Popup' | ||
import Icon from './Icon' | ||
import { WalletConnectErrorMessage } from '../SessionManager/ErrorMessage' | ||
|
||
export const ErrorFalllback = ({ | ||
onOpen, | ||
onClose, | ||
open, | ||
error, | ||
}: { | ||
onOpen: () => void | ||
onClose: () => void | ||
open: boolean | ||
error: Error | ||
}): ReactElement => { | ||
const iconRef = useRef<HTMLDivElement>(null) | ||
|
||
return ( | ||
<> | ||
<div ref={iconRef}> | ||
<Icon onClick={onOpen} sessionCount={0} error /> | ||
</div> | ||
|
||
<Popup anchorEl={iconRef.current} open={open} onClose={onClose}> | ||
<WalletConnectErrorMessage error={error} /> | ||
</Popup> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { popupSlice, PopupType } from '@/store/popupSlice' | ||
import { CookieType } from '../cookiesSlice' | ||
|
||
describe('popupSlice', () => { | ||
it('should open the cookie banner', () => { | ||
const initialState = { | ||
[PopupType.COOKIES]: { open: false }, | ||
[PopupType.WALLET_CONNECT]: { open: false }, | ||
} | ||
const { reducer, actions } = popupSlice | ||
const newState = reducer(initialState, actions.openCookieBanner({ warningKey: CookieType.ANALYTICS })) | ||
expect(newState[PopupType.COOKIES]).toEqual({ open: true, warningKey: CookieType.ANALYTICS }) | ||
}) | ||
|
||
it('should close the cookie banner', () => { | ||
const initialState = { | ||
[PopupType.COOKIES]: { open: true }, | ||
[PopupType.WALLET_CONNECT]: { open: false }, | ||
} | ||
const { reducer, actions } = popupSlice | ||
const newState = reducer(initialState, actions.closeCookieBanner()) | ||
expect(newState[PopupType.COOKIES]).toEqual({ open: false }) | ||
}) | ||
|
||
it('should open the wallet connect popup', () => { | ||
const initialState = { | ||
[PopupType.COOKIES]: { open: false }, | ||
[PopupType.WALLET_CONNECT]: { open: false }, | ||
} | ||
const { reducer, actions } = popupSlice | ||
const newState = reducer(initialState, actions.openWalletConnect()) | ||
expect(newState[PopupType.WALLET_CONNECT]).toEqual({ open: true }) | ||
}) | ||
|
||
it('should close the wallet connect popup', () => { | ||
const initialState = { | ||
[PopupType.COOKIES]: { open: false }, | ||
[PopupType.WALLET_CONNECT]: { open: true }, | ||
} | ||
const { reducer, actions } = popupSlice | ||
const newState = reducer(initialState, actions.closeWalletConnect()) | ||
expect(newState[PopupType.WALLET_CONNECT]).toEqual({ open: false }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters