on afdb680 help sign in
bridge/src/views/Point/AddressButton.tsx
29 lines 768 B history raw
1import * as need from 'lib/need';
2import { Button, ButtonProps } from '@tlon/indigo-react';
3import { useCallback } from 'react';
4import { useForm } from 'react-final-form';
5import { useWallet } from 'store/wallet';
7interface AddressButtonProps {
8 children?: React.ReactNode;
9 rest?: ButtonProps;
12export const AddressButton = ({ children, ...rest }: AddressButtonProps) => {
13 const { change } = useForm();
14 const { wallet }: any = useWallet();
15 const address = need.addressFromWallet(wallet);
17 const onClick = useCallback(
18 (_event: React.MouseEvent<HTMLSpanElement>) => {
19 change('owner', address);
20 },
21 [address, change]
22 );
24 return (
25 <Button onClick={onClick} {...rest} className={'secondary'}>
26 {children}
27 </Button>
28 );
29};