mirror of
https://github.com/Such-Software/xmrcheckout.git
synced 2026-10-17 05:51:34 +02:00
Redesign create invoice modal
This commit is contained in:
@@ -77,12 +77,12 @@ export async function createInvoiceAction(
|
|||||||
const isFiat = amountMode === "fiat";
|
const isFiat = amountMode === "fiat";
|
||||||
const instantConfirmation = formData.get("instant_confirmation") === "1";
|
const instantConfirmation = formData.get("instant_confirmation") === "1";
|
||||||
const confirmationRaw = String(formData.get("confirmation_target") ?? "").trim();
|
const confirmationRaw = String(formData.get("confirmation_target") ?? "").trim();
|
||||||
const confirmationTarget = instantConfirmation ? 0 : Number(confirmationRaw);
|
let confirmationTarget: number | null = null;
|
||||||
if (
|
if (instantConfirmation) {
|
||||||
Number.isNaN(confirmationTarget) ||
|
confirmationTarget = 0;
|
||||||
confirmationTarget < 0 ||
|
} else if (confirmationRaw) {
|
||||||
confirmationTarget > 10
|
const parsed = Number(confirmationRaw);
|
||||||
) {
|
if (Number.isNaN(parsed) || parsed < 0 || parsed > 10) {
|
||||||
return {
|
return {
|
||||||
error: "Confirmation target must be between 0 and 10.",
|
error: "Confirmation target must be between 0 and 10.",
|
||||||
invoiceId: null,
|
invoiceId: null,
|
||||||
@@ -94,6 +94,8 @@ export async function createInvoiceAction(
|
|||||||
warnings: null,
|
warnings: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
confirmationTarget = parsed;
|
||||||
|
}
|
||||||
const amountRaw = String(
|
const amountRaw = String(
|
||||||
formData.get(isFiat ? "amount_fiat" : "amount_xmr") ?? ""
|
formData.get(isFiat ? "amount_fiat" : "amount_xmr") ?? ""
|
||||||
).trim();
|
).trim();
|
||||||
@@ -245,7 +247,7 @@ export async function createInvoiceAction(
|
|||||||
amount_xmr: isFiat ? null : amountRaw,
|
amount_xmr: isFiat ? null : amountRaw,
|
||||||
amount_fiat: isFiat ? amountRaw : null,
|
amount_fiat: isFiat ? amountRaw : null,
|
||||||
currency: isFiat ? currency : null,
|
currency: isFiat ? currency : null,
|
||||||
confirmation_target: confirmationTarget,
|
...(confirmationTarget !== null ? { confirmation_target: confirmationTarget } : {}),
|
||||||
expires_at: expiresAt,
|
expires_at: expiresAt,
|
||||||
checkout_continue_url: checkoutContinueUrlRaw || null,
|
checkout_continue_url: checkoutContinueUrlRaw || null,
|
||||||
metadata:
|
metadata:
|
||||||
|
|||||||
+578
-584
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user