Skip to content

Commit

Permalink
Add suggestions to recipient input
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Sep 6, 2023
1 parent 6b9ca2b commit e2c1399
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app/pages/AccountPage/Features/SendTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useModal } from 'app/components/Modal'
import { transactionActions } from 'app/state/transaction'
import { selectTransaction } from 'app/state/transaction/selectors'
import { selectValidators } from 'app/state/staking/selectors'
import { selectContactsList } from 'app/state/contacts/selectors'
import { Box } from 'grommet/es6/components/Box'
import { Button } from 'grommet/es6/components/Button'
import { Form } from 'grommet/es6/components/Form'
Expand All @@ -28,6 +29,7 @@ export function SendTransaction(props: SendTransactionProps) {
const { launchModal } = useModal()
const { error, success } = useSelector(selectTransaction)
const validators = useSelector(selectValidators)
const contracts = useSelector(selectContactsList)
const [recipient, setRecipient] = useState('')
const [amount, setAmount] = useState('')
const sendTransaction = () =>
Expand Down Expand Up @@ -83,6 +85,10 @@ export function SendTransaction(props: SendTransactionProps) {
>
<TextInput
id="recipient-id"
suggestions={contracts.map(contract => contract.name)}

Check warning on line 88 in src/app/pages/AccountPage/Features/SendTransaction/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/pages/AccountPage/Features/SendTransaction/index.tsx#L88

Added line #L88 was not covered by tests
onSuggestionSelect={event =>
setRecipient(contracts.find(contract => contract.name === event.suggestion)?.address || '')

Check warning on line 90 in src/app/pages/AccountPage/Features/SendTransaction/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/pages/AccountPage/Features/SendTransaction/index.tsx#L90

Added line #L90 was not covered by tests
}
name="recipient"
value={recipient}
placeholder={t('account.sendTransaction.enterAddress', 'Enter an address')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1211,12 +1211,15 @@ exports[`<AccountPage /> should match snapshot 1`] = `
class="c30"
>
<input
aria-autocomplete="list"
aria-expanded="false"
autocomplete="off"
class="c31"
id="recipient-id"
name="recipient"
placeholder="Enter an address"
required=""
role="combobox"
value=""
/>
</div>
Expand Down

0 comments on commit e2c1399

Please sign in to comment.