// Copyright 2017-2020 @polkadot/app-treasury authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import BN from 'bn.js'; import React, { useEffect, useState } from 'react'; import { Button, Input, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/react-components'; import { useToggle } from '@polkadot/react-hooks'; import { useTranslation } from '../translate'; interface Props { members: string[]; refresh: () => void; } const MAX_REASON_LEN = 128; const MIN_REASON_LEN = 5; function TipCreate ({ members, refresh }: Props): React.ReactElement { const { t } = useTranslation(); const [isOpen, toggleOpen] = useToggle(); const [accountId, setAccountId] = useState(null); const [beneficiary, setBeneficiary] = useState(null); const [isMember, setIsMember] = useState(false); const [reason, setReason] = useState(''); const [value, setValue] = useState(); const hasValue = value?.gtn(0); const hasReason = reason?.length >= MIN_REASON_LEN && reason?.length <= MAX_REASON_LEN; useEffect((): void => { setIsMember( accountId ? members.includes(accountId) : false ); }, [accountId, members]); return ( <>