Skip to content

Commit

Permalink
Set the initial value of the amount field to 0
Browse files Browse the repository at this point in the history
... instead of empty string.

Earlier the "0" was in the placeholder, but not in the actual value,
and this was causing some problems.
  • Loading branch information
csillag committed Sep 30, 2022
1 parent 3498dac commit c8e4972
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('<SendTransaction />', () => {
renderComponent(store)

await userEvent.type(screen.getByPlaceholderText('account.sendTransaction.enterAddress'), 'walletAddress')
await userEvent.type(screen.getByPlaceholderText('0'), '10')
await userEvent.type(screen.getByPlaceholderText('account.sendTransaction.enterAmount'), '10')
await userEvent.click(screen.getByRole('button'))

expect(spy).toHaveBeenCalledWith({
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/AccountPage/Features/SendTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function SendTransaction(props: SendTransactionProps) {
const { error, success } = useSelector(selectTransaction)
const validators = useSelector(selectValidators)
const [recipient, setRecipient] = useState('')
const [amount, setAmount] = useState('')
const [amount, setAmount] = useState('0')
const sendTransaction = () =>
dispatch(
transactionActions.sendTransaction({
Expand Down Expand Up @@ -90,7 +90,7 @@ export function SendTransaction(props: SendTransactionProps) {
<TextInput
id="amount-id"
name="amount"
placeholder="0"
placeholder={t('account.sendTransaction.enterAmount', 'Enter an amount')}
type="number"
step="any"
min="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,11 @@ exports[`<AccountPage /> should match snapshot 1`] = `
id="amount-id"
min="0"
name="amount"
placeholder="0"
placeholder="Enter an amount"
required=""
step="any"
type="number"
value=""
value="0"
/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"title": "Are you sure you want to continue?"
},
"enterAddress": "Enter an address",
"enterAmount": "Enter an amount",
"recipient": "Recipient",
"send": "Send",
"success": "Transaction successfully sent. The transaction might take up to a minute to appear on your account."
Expand Down

0 comments on commit c8e4972

Please sign in to comment.