2022-06-01 14:21:36 +00:00
|
|
|
import type { ReactNode } from 'react';
|
2023-02-28 18:56:29 +00:00
|
|
|
import { t } from '@vegaprotocol/i18n';
|
2022-06-01 14:21:36 +00:00
|
|
|
import { Button, Splash } from '@vegaprotocol/ui-toolkit';
|
2022-10-14 15:42:53 +00:00
|
|
|
import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet';
|
2022-06-01 14:21:36 +00:00
|
|
|
|
|
|
|
interface VegaWalletContainerProps {
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => {
|
2022-10-14 15:42:53 +00:00
|
|
|
const { openVegaWalletDialog } = useVegaWalletDialogStore((store) => ({
|
|
|
|
openVegaWalletDialog: store.openVegaWalletDialog,
|
|
|
|
}));
|
2022-10-03 18:12:34 +00:00
|
|
|
const { pubKey } = useVegaWallet();
|
2022-06-01 14:21:36 +00:00
|
|
|
|
2022-10-03 18:12:34 +00:00
|
|
|
if (!pubKey) {
|
2022-06-01 14:21:36 +00:00
|
|
|
return (
|
|
|
|
<Splash>
|
|
|
|
<div className="text-center">
|
2022-08-31 04:35:46 +00:00
|
|
|
<p className="mb-4" data-testid="connect-vega-wallet-text">
|
2022-06-01 14:21:36 +00:00
|
|
|
{t('Connect your Vega wallet')}
|
|
|
|
</p>
|
|
|
|
<Button
|
2022-10-14 15:42:53 +00:00
|
|
|
onClick={openVegaWalletDialog}
|
2022-06-01 14:21:36 +00:00
|
|
|
data-testid="vega-wallet-connect"
|
|
|
|
>
|
|
|
|
{t('Connect')}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Splash>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <>{children}</>;
|
|
|
|
};
|