Skip to content

Commit

Permalink
chore: update text from send to transfer for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Jan 8, 2024
1 parent dd6535f commit d07fd35
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const RegisteredInterchainTokenCard: FC<Props> = (props) => {
className="absolute right-6"
disabled={!props.hasRemoteTokens}
>
send
Transfer
</Button>
}
tokenAddress={props.tokenAddress}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ describe("SendInterchainToken", () => {
})
).toMatchInlineSnapshot(`
<span
aria-label="set max balance to send"
aria-label="set max balance to transfer"
class="label-text-alt"
role="button"
>
Balance:
100,000,000
</span>
`);
Expand Down Expand Up @@ -150,21 +150,22 @@ describe("SendInterchainToken", () => {

// type in an amount
await user.type(
screen.getByPlaceholderText("Enter your amount to send"),
screen.getByPlaceholderText("Enter your amount to transfer"),
"100"
);

expect(screen.getByRole("button", { name: /Send/ })).toMatchInlineSnapshot(`
expect(screen.getByRole("button", { name: /Transfer/ }))
.toMatchInlineSnapshot(`
<button
class="btn btn-primary"
type="submit"
>
Send
Transfer
100
tokens
to
Ethereum Mainnet
</button>
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import GMPTxStatusMonitor from "~/ui/compounds/GMPTxStatusMonitor";
import { useSendInterchainTokenState } from "./SendInterchainToken.state";

type FormState = {
amountToSend: string;
amountToTransfer: string;
};

type Props = {
Expand Down Expand Up @@ -57,7 +57,7 @@ export const SendInterchainToken: FC<Props> = (props) => {
reValidateMode: "onChange",
});

const amountToSend = watch("amountToSend");
const amountToTransfer = watch("amountToTransfer");

const submitHandler: SubmitHandler<FormState> = async (data, e) => {
e?.preventDefault();
Expand All @@ -67,13 +67,13 @@ export const SendInterchainToken: FC<Props> = (props) => {
await actions.sendTokenAsync(
{
tokenAddress: props.tokenAddress,
amount: data.amountToSend,
amount: data.amountToTransfer,
},
{
// handles unhandled errors in the mutation
onError(error) {
if (error instanceof Error) {
toast.error("Failed to send token. Please try again.");
toast.error("Failed to transfer token. Please try again.");
logger.always.error(error);
}
},
Expand All @@ -82,7 +82,7 @@ export const SendInterchainToken: FC<Props> = (props) => {
};

const buttonChildren = useMemo(() => {
const pluralized = `token${Number(amountToSend) > 1 ? "s" : ""}`;
const pluralized = `token${Number(amountToTransfer) > 1 ? "s" : ""}`;

switch (state.txState?.status) {
case "awaiting_spend_approval":
Expand All @@ -92,23 +92,26 @@ export const SendInterchainToken: FC<Props> = (props) => {
case "submitted":
return (
<>
Sending {amountToSend} {pluralized} to {state.selectedToChain?.name}
Transferring {amountToTransfer} {pluralized} to{" "}
{state.selectedToChain?.name}
</>
);
default:
if (!formState.isValid) {
return formState.errors.amountToSend?.message ?? "Amount is required";
return (
formState.errors.amountToTransfer?.message ?? "Amount is required"
);
}
return (
<>
Send {amountToSend || 0} {pluralized} to{" "}
Transfer {amountToTransfer || 0} {pluralized} to{" "}
{state.selectedToChain?.name}
</>
);
}
}, [
amountToSend,
formState.errors.amountToSend?.message,
amountToTransfer,
formState.errors.amountToTransfer?.message,
formState.isValid,
state.selectedToChain?.name,
state.txState?.status,
Expand Down Expand Up @@ -204,14 +207,14 @@ export const SendInterchainToken: FC<Props> = (props) => {
onSubmit={handleSubmit(submitHandler)}
>
<FormControl>
<Label htmlFor="amountToSend">
<Label.Text>Amount to send</Label.Text>
<Label htmlFor="amountToTransfer">
<Label.Text>Amount to transfer</Label.Text>
<Label.AltText
role="button"
aria-label="set max balance to send"
aria-label="set max balance to transfer"
onClick={() => {
setValue(
"amountToSend",
"amountToTransfer",
formatUnits(
BigInt(props.balance.tokenBalance),
Number(props.balance.decimals)
Expand All @@ -233,13 +236,13 @@ export const SendInterchainToken: FC<Props> = (props) => {
</Label.AltText>
</Label>
<TextInput
id="amountToSend"
id="amountToTransfer"
bordered
placeholder="Enter your amount to send"
placeholder="Enter your amount to transfer"
className="bg-base-200"
min={0}
onKeyDown={preventNonNumericInput}
{...register("amountToSend", {
{...register("amountToTransfer", {
disabled: isFormDisabled,
validate(value) {
if (!value || value === "0") {
Expand Down

0 comments on commit d07fd35

Please sign in to comment.