-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: removed content in favor of children
- Loading branch information
1 parent
98fe8a0
commit a47bf40
Showing
7 changed files
with
388 additions
and
400 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
83 changes: 25 additions & 58 deletions
83
packages/beacon-ui/src/components/pair-other/pair-other.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 |
---|---|---|
@@ -1,88 +1,55 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import QR from "../qr"; | ||
import { MergedWallet } from "../../utils/wallets"; | ||
import { | ||
P2PPairingRequest, | ||
WalletConnectPairingRequest, | ||
} from "@airgap/beacon-types"; | ||
import React, { useState, useEffect } from 'react' | ||
import QR from '../qr' | ||
|
||
import { Serializer } from "@airgap/beacon-core"; | ||
|
||
export interface PairOtherProps { | ||
walletList: MergedWallet[]; | ||
p2pPayload: Promise<P2PPairingRequest> | undefined; | ||
wcPayload: Promise<WalletConnectPairingRequest> | undefined; | ||
onClickLearnMore: () => void; | ||
} | ||
import { PairOtherProps } from 'src/ui/alert/common' | ||
|
||
const PairOther: React.FC<PairOtherProps> = (props: PairOtherProps) => { | ||
const [uiState, setUiState] = useState<"selection" | "p2p" | "walletconnect">( | ||
"selection" | ||
); | ||
const [hasBeacon, setHasBeacon] = useState<boolean>(false); | ||
const [hasWalletConnect, setHasWalletConnect] = useState<boolean>(false); | ||
const [qrData, setQrData] = useState<string>(""); | ||
const [uiState, setUiState] = useState<'selection' | 'p2p' | 'walletconnect'>('selection') | ||
const [hasBeacon, setHasBeacon] = useState<boolean>(false) | ||
const [hasWalletConnect, setHasWalletConnect] = useState<boolean>(false) | ||
const [qrData, setQrData] = useState<string>('') | ||
|
||
useEffect(() => { | ||
setUiState("selection"); | ||
setQrData(""); | ||
setHasBeacon(!!props.p2pPayload); | ||
setHasWalletConnect(!!props.wcPayload); | ||
}, [props.p2pPayload, props.wcPayload]); | ||
setUiState('selection') | ||
setQrData('') | ||
setHasBeacon(!!props.p2pPayload) | ||
setHasWalletConnect(!!props.wcPayload) | ||
}, [props.p2pPayload, props.wcPayload]) | ||
|
||
const buttonClickHandler = (state: "p2p" | "walletconnect") => { | ||
if (state === "p2p" && props.p2pPayload) { | ||
props.p2pPayload.then(async (payload) => { | ||
const serializer = new Serializer(); | ||
const codeQR = await serializer.serialize(payload); | ||
setQrData(codeQR); | ||
}); | ||
} else if (state === "walletconnect" && props.wcPayload) { | ||
props.wcPayload | ||
.then((payload) => { | ||
setQrData(payload.uri); | ||
}) | ||
.catch((error) => console.error(error.message)); | ||
} | ||
setUiState(state); | ||
}; | ||
const buttonClickHandler = (state: 'p2p' | 'walletconnect') => { | ||
state === 'p2p' ? setQrData(props.p2pPayload) : setQrData(props.wcPayload) | ||
setUiState(state) | ||
} | ||
|
||
return ( | ||
<> | ||
{uiState === "selection" && ( | ||
{uiState === 'selection' && ( | ||
<div> | ||
<span className="pair-other-info">Select QR Type</span> | ||
<br /> | ||
{hasBeacon && ( | ||
<button | ||
className="wallets-button" | ||
onClick={() => buttonClickHandler("p2p")} | ||
> | ||
<button className="wallets-button" onClick={() => buttonClickHandler('p2p')}> | ||
Beacon | ||
</button> | ||
)} | ||
{hasWalletConnect && ( | ||
<button | ||
className="wallets-button" | ||
onClick={() => buttonClickHandler("walletconnect")} | ||
> | ||
<button className="wallets-button" onClick={() => buttonClickHandler('walletconnect')}> | ||
WalletConnect | ||
</button> | ||
)} | ||
</div> | ||
)} | ||
{uiState !== "selection" && qrData && ( | ||
{uiState !== 'selection' && qrData && ( | ||
<QR | ||
isWalletConnect={uiState === "walletconnect"} | ||
isWalletConnect={uiState === 'walletconnect'} | ||
isMobile={true} | ||
walletName={"AirGap"} | ||
walletName={'AirGap'} | ||
code={qrData} | ||
onClickLearnMore={props.onClickLearnMore} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
) | ||
} | ||
|
||
export default PairOther; | ||
export default PairOther |
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
5 changes: 3 additions & 2 deletions
5
packages/beacon-ui/src/ui/alert/components/alert-content/index.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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { AlertConfig } from '../../common' | ||
import PairingAlert from '../pairing-alert' | ||
|
||
const AlertContent = () => { | ||
return <PairingAlert /> | ||
const AlertContent = (props: AlertConfig) => { | ||
return <PairingAlert {...props} /> | ||
} | ||
|
||
export default AlertContent |
Oops, something went wrong.