vega-frontend-monorepo/apps/token/src/components/vega-wallet-container/vega-wallet-container.tsx
Radosław Szpiech acef1a8e24
Test/toke add withdraw page validations (#701)
* fix: always show heading on governance page

* test(token): added validation for withdraw and governance pages

* chore: remove semicolon

Co-authored-by: Dexter <dexter.edwards93@gmail.com>
Co-authored-by: Rado <rado@vegaprotocol.io>
2022-07-01 16:57:20 +02:00

41 lines
1.0 KiB
TypeScript

import { Button } from '@vegaprotocol/ui-toolkit';
import type { VegaKeyExtended } from '@vegaprotocol/wallet';
import { useVegaWallet } from '@vegaprotocol/wallet';
import React from 'react';
import { useTranslation } from 'react-i18next';
import {
AppStateActionType,
useAppState,
} from '../../contexts/app-state/app-state-context';
interface VegaWalletContainerProps {
children: (key: VegaKeyExtended) => React.ReactElement;
}
export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => {
const { t } = useTranslation();
const { keypair } = useVegaWallet();
const { appDispatch } = useAppState();
if (!keypair) {
return (
<p>
<Button
data-testid="connect-to-vega-wallet-btn"
onClick={() =>
appDispatch({
type: AppStateActionType.SET_VEGA_WALLET_OVERLAY,
isOpen: true,
})
}
>
{t('connectVegaWallet')}
</Button>
</p>
);
}
return children(keypair);
};