diff --git a/public/locales/en.json b/public/locales/en.json
index 0199ef5..a4215dc 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -1022,6 +1022,19 @@
"errorInvalidQuery": "The query parameters were invalid, they were ignored."
},
+ "request": {
+ "title": "Request Krist",
+ "siteTitle": "Request Krist",
+
+ "labelTo": "Request recipient",
+ "labelAmount": "Request amount",
+ "labelMetadata": "Request metadata",
+ "placeholderMetadata": "Metadata",
+
+ "generatedLink": "Generated link",
+ "generatedLinkHint": "Send this link to somebody to request a payment from them."
+ },
+
"authFailed": {
"title": "Auth failed",
"message": "You do not own this address.",
diff --git a/src/components/transactions/AmountInput.tsx b/src/components/transactions/AmountInput.tsx
index 5f5e3f4..806f1da 100644
--- a/src/components/transactions/AmountInput.tsx
+++ b/src/components/transactions/AmountInput.tsx
@@ -1,6 +1,7 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under AGPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
+import { ReactNode } from "react";
import { Form, Input, InputNumber, Button } from "antd";
import { useTranslation } from "react-i18next";
@@ -13,12 +14,22 @@
interface Props {
from?: string;
setAmount: (amount: number) => void;
+
+ label?: ReactNode;
+ required?: boolean;
+ disabled?: boolean;
+
tabIndex?: number;
}
export function AmountInput({
from,
setAmount,
+
+ label,
+ required,
+ disabled,
+
tabIndex,
...props
}: Props): JSX.Element {
@@ -36,9 +47,11 @@
setAmount(currentWallet?.balance || 0);
}
+ const amountRequired = required === undefined || !!required;
+
return
@@ -57,13 +70,19 @@
validateFirst
rules={[
- { required: true, message: t("sendTransaction.errorAmountRequired") },
- { type: "number", message: t("sendTransaction.errorAmountNumber") },
+ { required: amountRequired,
+ message: t("sendTransaction.errorAmountRequired") },
+ { type: "number",
+ message: t("sendTransaction.errorAmountNumber") },
// Validate that the number isn't higher than the selected wallet's
- // balance
+ // balance, if it is present
{
async validator(_, value): Promise {
+ // If the field isn't required, don't complain if it's empty
+ if (!required && typeof value !== "number")
+ return;
+
if (value < 1)
throw t("sendTransaction.errorAmountTooLow");
@@ -83,6 +102,7 @@
min={1}
style={{ width: "100%", height: 32 }}
tabIndex={tabIndex}
+ disabled={disabled}
/>
@@ -92,7 +112,7 @@
{/* Max value button */}
- {from &&