Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | import { ErrorLabel } from '@components/error-label'; import { ErrorText } from '@components/error-text'; import { useAnalytics } from '@hooks/use-analytics'; import { Flex, Text, Input, Box, Button, color } from '@stacks/ui'; import { capitalize } from '@utils/capitalize'; import { toHumanReadableStx } from '@utils/unit-convert'; import { HomeSelectors } from 'app/tests/features/home.selectors'; import { FormikProps } from 'formik'; import React, { FC } from 'react'; interface TxModalFormProps { balance: string; form: FormikProps<{ recipient: string; amount: string; memo: string; noMemoRequired: boolean }>; isCalculatingMaxSpend: boolean; onSendEntireBalance(): void; feeEstimateError: string | null; } export const TxModalForm: FC<TxModalFormProps> = props => { const { balance, form, isCalculatingMaxSpend, feeEstimateError, onSendEntireBalance } = props; const analytics = useAnalytics(); const onSendEntireBalanceTracked = () => { void analytics.track('select_maximum_amount_for_send'); onSendEntireBalance(); }; return ( <Box mb="extra-loose"> <Flex flexDirection="column" alignItems="center" mt="48px"> <Text textStyle="body.large.medium">Available balance</Text> <Text textStyle="body.large.medium" fontWeight={600} mt="tight" fontSize="32px"> {toHumanReadableStx(balance)} </Text> </Flex> <Flex flexDirection="column" mt="40px" mx="extra-loose"> <Text textStyle="body.small.medium" as="label" {...{ htmlFor: 'stxAddress' }}> Send to </Text> <Input id="stxAddress" data-test={HomeSelectors.InputSendStxFormAddress} name="recipient" mt="base-tight" placeholder="STX address" onChange={form.handleChange} value={form.values.recipient} /> {form.touched.recipient && form.errors.recipient && ( <ErrorLabel> <ErrorText>{form.errors.recipient}</ErrorText> </ErrorLabel> )} <Text textStyle="body.small.medium" mt="base-loose" as="label" {...{ htmlFor: 'stxAmount' }} > Amount </Text> <Box position="relative"> <Input id="stxAmount" data-test={HomeSelectors.InputSendStxFormAmount} name="amount" inputMode="numeric" pattern="[0-9]*" mt="base-tight" placeholder="0.000000 STX" onChange={form.handleChange} value={form.values.amount} /> {form.touched.amount && form.errors.amount && ( <ErrorLabel> <ErrorText>{capitalize(form.errors.amount)}</ErrorText> </ErrorLabel> )} <Button mode="tertiary" type="button" size="sm" height="28px" right="12px" top="22px" style={{ position: 'absolute' }} width="80px" onClick={onSendEntireBalanceTracked} isLoading={isCalculatingMaxSpend} > Send max </Button> </Box> <Text textStyle="body.small.medium" mt="base-loose" mr="extra-tight" as="label" {...{ htmlFor: 'stxAmount' }} > Memo </Text> <Text textStyle="body.small" color={color('text-caption')} mt="tight"> Exchanges often require a memo to credit the STX to your account. </Text> <Flex as="label" textStyle="body.small" color={color('text-body')} mt="base-tight" alignItems="baseline" > <Box mr="tight" mt="1px"> <input type="checkbox" id="noMemoRequired" name="noMemoRequired" onChange={form.handleChange} checked={form.values.noMemoRequired} /> </Box> I confirm no memo is required for this transaction </Flex> <Input id="memo" data-test={HomeSelectors.InputSendStxFormMemo} name="memo" inputMode="numeric" mt="base-loose" placeholder="Memo" isDisabled={form.values.noMemoRequired} onChange={form.handleChange} value={form.values.memo} /> {form.touched.memo && form.errors.memo && ( <ErrorLabel> <ErrorText>{capitalize(form.errors.memo)}</ErrorText> </ErrorLabel> )} {feeEstimateError && ( <ErrorLabel> <ErrorText>{feeEstimateError}</ErrorText> </ErrorLabel> )} </Flex> </Box> ); }; |