import React from 'react'; import { Button, Form, Input, Tooltip } from 'antd'; import { TipJarModal } from './TipJarModal'; import { getAmountErrorFromString } from 'utils/validators'; import './TipJarBlock.less'; import '../Proposal/index.less'; interface Props { address?: string | null; type: 'user' | 'proposal'; } const STATE = { tipAmount: '', modalOpen: false, }; type State = typeof STATE; export class TipJarBlock extends React.Component { state = STATE; render() { const { address, type } = this.props; const { tipAmount, modalOpen } = this.state; const amountError = tipAmount ? getAmountErrorFromString(tipAmount) : ''; const addressNotSet = !address; const buttonTooltip = addressNotSet ? `Tipping address has not been set for ${type}` : ''; const isDisabled = addressNotSet || !tipAmount || !!amountError; return (
{address && tipAmount && ( )}
); } private handleAmountChange = (e: React.ChangeEvent) => this.setState({ tipAmount: e.currentTarget.value, }); private handleTipJarModalOpen = () => this.setState({ modalOpen: true, }); private handleTipJarModalClose = () => this.setState({ modalOpen: false, }); }