From a47bf40e20ba202499d494346ffef3c2c33cd88a Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 10 Sep 2024 14:32:45 +0200 Subject: [PATCH] fix: removed content in favor of children --- .../beacon-ui/src/components/alert/index.tsx | 4 +- .../src/components/pair-other/pair-other.tsx | 83 +-- .../beacon-ui/src/components/wallet/index.tsx | 1 - packages/beacon-ui/src/ui/alert/common.ts | 11 +- .../alert/components/alert-content/index.tsx | 5 +- .../alert/components/pairing-alert/index.tsx | 669 +++++++++--------- packages/beacon-ui/src/ui/alert/index.tsx | 15 +- 7 files changed, 388 insertions(+), 400 deletions(-) diff --git a/packages/beacon-ui/src/components/alert/index.tsx b/packages/beacon-ui/src/components/alert/index.tsx index 522e933bc..dced5e239 100644 --- a/packages/beacon-ui/src/components/alert/index.tsx +++ b/packages/beacon-ui/src/components/alert/index.tsx @@ -4,7 +4,7 @@ import { LeftIcon, LogoIcon, CloseIcon } from '../icons' // import Loader from '../loader' import useIsMobile from 'src/ui/alert/hooks/useIsMobile' -const Alert: React.FC = (props: AlertProps) => { +const Alert: React.FC> = (props) => { const isMobile = useIsMobile() return ( @@ -33,7 +33,7 @@ const Alert: React.FC = (props: AlertProps) => { - {props.content} + {props.children} {!isMobile && ( {props.extraContent && ---} diff --git a/packages/beacon-ui/src/components/pair-other/pair-other.tsx b/packages/beacon-ui/src/components/pair-other/pair-other.tsx index 1a7770e2e..f1e632fa3 100644 --- a/packages/beacon-ui/src/components/pair-other/pair-other.tsx +++ b/packages/beacon-ui/src/components/pair-other/pair-other.tsx @@ -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 | undefined; - wcPayload: Promise | undefined; - onClickLearnMore: () => void; -} +import { PairOtherProps } from 'src/ui/alert/common' const PairOther: React.FC = (props: PairOtherProps) => { - const [uiState, setUiState] = useState<"selection" | "p2p" | "walletconnect">( - "selection" - ); - const [hasBeacon, setHasBeacon] = useState(false); - const [hasWalletConnect, setHasWalletConnect] = useState(false); - const [qrData, setQrData] = useState(""); + const [uiState, setUiState] = useState<'selection' | 'p2p' | 'walletconnect'>('selection') + const [hasBeacon, setHasBeacon] = useState(false) + const [hasWalletConnect, setHasWalletConnect] = useState(false) + const [qrData, setQrData] = useState('') 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' && (
Select QR Type
{hasBeacon && ( - )} {hasWalletConnect && ( - )}
)} - {uiState !== "selection" && qrData && ( + {uiState !== 'selection' && qrData && ( )} - ); -}; - + ) +} -export default PairOther; +export default PairOther diff --git a/packages/beacon-ui/src/components/wallet/index.tsx b/packages/beacon-ui/src/components/wallet/index.tsx index 08dca2d3e..259e2b306 100644 --- a/packages/beacon-ui/src/components/wallet/index.tsx +++ b/packages/beacon-ui/src/components/wallet/index.tsx @@ -13,7 +13,6 @@ interface WalletProps { } const Wallet: React.FC = (props: WalletProps) => { - console.log(props.name, props.tags) return (