diff options
Diffstat (limited to 'demobank/index.js')
-rw-r--r-- | demobank/index.js | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/demobank/index.js b/demobank/index.js index 9cc185502..cf8ea5eda 100644 --- a/demobank/index.js +++ b/demobank/index.js @@ -24799,7 +24799,14 @@ function useCashinEstimator() { credit: fiatAmount }); if (resp.type === "fail") { - throw TalerError.fromDetail(resp.detail.code, {}, resp.detail.hint); + switch (resp.case) { + case HttpStatusCode.Conflict: { + return "amount-is-too-small"; + } + case HttpStatusCode.NotImplemented: + case HttpStatusCode.BadRequest: + throw TalerError.fromDetail(resp.detail.code, {}, resp.detail.hint); + } } const credit = Amounts.parseOrThrow(resp.body.amount_credit); const debit = Amounts.parseOrThrow(resp.body.amount_debit); @@ -24815,7 +24822,14 @@ function useCashinEstimator() { debit: regionalAmount }); if (resp.type === "fail") { - throw TalerError.fromDetail(resp.detail.code, {}, resp.detail.hint); + switch (resp.case) { + case HttpStatusCode.Conflict: { + return "amount-is-too-small"; + } + case HttpStatusCode.NotImplemented: + case HttpStatusCode.BadRequest: + throw TalerError.fromDetail(resp.detail.code, {}, resp.detail.hint); + } } const credit = Amounts.parseOrThrow(resp.body.amount_credit); const debit = Amounts.parseOrThrow(resp.body.amount_debit); @@ -24859,7 +24873,14 @@ function useCashoutEstimator() { debit: regionalAmount }); if (resp.type === "fail") { - throw TalerError.fromDetail(resp.detail.code, {}, resp.detail.hint); + switch (resp.case) { + case HttpStatusCode.Conflict: { + return "amount-is-too-small"; + } + case HttpStatusCode.NotImplemented: + case HttpStatusCode.BadRequest: + throw TalerError.fromDetail(resp.detail.code, {}, resp.detail.hint); + } } const credit = Amounts.parseOrThrow(resp.body.amount_credit); const debit = Amounts.parseOrThrow(resp.body.amount_debit); @@ -29466,7 +29487,7 @@ var AccountPage = utils_exports.compose( // src/pages/BankFrame.tsx init_preact_module(); init_hooks_module(); -var GIT_HASH = true ? "73ab9970e17f2a4749bad88631a4bd4d8e64721e" : void 0; +var GIT_HASH = true ? "a63b2a878b374f3076990131977f16d923d8a63b" : void 0; var VERSION = true ? "0.9.3-dev.29" : void 0; function BankFrame({ children, @@ -35198,7 +35219,8 @@ function CreateCashout({ class: "block text-sm font-medium leading-6 text-gray-900", for: "subject" }, - i18n2.str`Transfer subject` + i18n2.str`Transfer subject`, + /* @__PURE__ */ h("b", { style: { color: "red" } }, " *") ), /* @__PURE__ */ h("div", { class: "mt-2" }, /* @__PURE__ */ h( "input", { @@ -35228,7 +35250,8 @@ function CreateCashout({ class: "block text-sm font-medium leading-6 text-gray-900", for: "amount" }, - form.isDebit ? i18n2.str`Amount to send` : i18n2.str`Amount to receive` + form.isDebit ? i18n2.str`Amount to send` : i18n2.str`Amount to receive`, + /* @__PURE__ */ h("b", { style: { color: "red" } }, " *") ), /* @__PURE__ */ h( "button", { @@ -36946,7 +36969,7 @@ function useComponentState5({ const { estimateByDebit: calculateCashinFromDebit } = useCashinEstimator(); - const [calc, setCalc] = p3(); + const [calculationResult, setCalc] = p3(); h2(() => { function doAsync() { return __async(this, null, function* () { @@ -36959,6 +36982,10 @@ function useComponentState5({ const in_amount = Amounts.parseOrThrow(`${info.fiat_currency}:${form.amount.value}`); const in_fee = Amounts.parseOrThrow(info.conversion_rate.cashin_fee); const cashin = yield calculateCashinFromDebit(in_amount, in_fee); + if (cashin === "amount-is-too-small") { + setCalc(void 0); + return; + } const out_fee = Amounts.parseOrThrow(info.conversion_rate.cashout_fee); const cashout = yield calculateCashoutFromDebit(cashin.credit, out_fee); setCalc({ cashin, cashout }); @@ -36968,6 +36995,8 @@ function useComponentState5({ doAsync(); }, [(_a = form.amount) == null ? void 0 : _a.value, (_c = (_b = form.conv) == null ? void 0 : _b.cashin_fee) == null ? void 0 : _c.value, (_e = (_d = form.conv) == null ? void 0 : _d.cashout_fee) == null ? void 0 : _e.value]); const [section, setSection] = p3("detail"); + const cashinCalc = (calculationResult == null ? void 0 : calculationResult.cashin) === "amount-is-too-small" ? void 0 : calculationResult == null ? void 0 : calculationResult.cashin; + const cashoutCalc = (calculationResult == null ? void 0 : calculationResult.cashout) === "amount-is-too-small" ? void 0 : calculationResult == null ? void 0 : calculationResult.cashout; function doUpdate() { return __async(this, null, function* () { if (!creds) @@ -37138,49 +37167,49 @@ function useComponentState5({ message: (_s = form.amount) == null ? void 0 : _s.error, isDirty: ((_t = form.amount) == null ? void 0 : _t.value) !== void 0 } - ), /* @__PURE__ */ h("p", { class: "mt-2 text-sm text-gray-500" }, /* @__PURE__ */ h(i18n2.Translate, null, "Use it to test how the conversion will affect the amount."))))), !calc ? void 0 : /* @__PURE__ */ h("div", { class: "px-6 pt-6" }, /* @__PURE__ */ h("div", { class: "sm:col-span-5" }, /* @__PURE__ */ h("dl", { class: "mt-4 space-y-4" }, /* @__PURE__ */ h("div", { class: "justify-between items-center flex " }, /* @__PURE__ */ h("dt", { class: "text-sm text-gray-600" }, /* @__PURE__ */ h(i18n2.Translate, null, "Sending to this bank")), /* @__PURE__ */ h("dd", { class: "text-sm text-gray-900" }, /* @__PURE__ */ h( + ), /* @__PURE__ */ h("p", { class: "mt-2 text-sm text-gray-500" }, /* @__PURE__ */ h(i18n2.Translate, null, "Use it to test how the conversion will affect the amount."))))), !cashoutCalc || !cashinCalc ? void 0 : /* @__PURE__ */ h("div", { class: "px-6 pt-6" }, /* @__PURE__ */ h("div", { class: "sm:col-span-5" }, /* @__PURE__ */ h("dl", { class: "mt-4 space-y-4" }, /* @__PURE__ */ h("div", { class: "justify-between items-center flex " }, /* @__PURE__ */ h("dt", { class: "text-sm text-gray-600" }, /* @__PURE__ */ h(i18n2.Translate, null, "Sending to this bank")), /* @__PURE__ */ h("dd", { class: "text-sm text-gray-900" }, /* @__PURE__ */ h( RenderAmount, { - value: calc.cashin.debit, + value: cashinCalc.debit, negative: true, withColor: true, spec: info.regional_currency_specification } - ))), Amounts.isZero(calc.cashin.beforeFee) ? void 0 : /* @__PURE__ */ h("div", { class: "flex items-center justify-between afu " }, /* @__PURE__ */ h("dt", { class: "flex items-center text-sm text-gray-600" }, /* @__PURE__ */ h("span", null, /* @__PURE__ */ h(i18n2.Translate, null, "Converted"))), /* @__PURE__ */ h("dd", { class: "text-sm text-gray-900" }, /* @__PURE__ */ h( + ))), Amounts.isZero(cashinCalc.beforeFee) ? void 0 : /* @__PURE__ */ h("div", { class: "flex items-center justify-between afu " }, /* @__PURE__ */ h("dt", { class: "flex items-center text-sm text-gray-600" }, /* @__PURE__ */ h("span", null, /* @__PURE__ */ h(i18n2.Translate, null, "Converted"))), /* @__PURE__ */ h("dd", { class: "text-sm text-gray-900" }, /* @__PURE__ */ h( RenderAmount, { - value: calc.cashin.beforeFee, + value: cashinCalc.beforeFee, spec: info.fiat_currency_specification } ))), /* @__PURE__ */ h("div", { class: "flex justify-between items-center border-t-2 afu pt-4" }, /* @__PURE__ */ h("dt", { class: "text-lg text-gray-900 font-medium" }, /* @__PURE__ */ h(i18n2.Translate, null, "Cashin after fee")), /* @__PURE__ */ h("dd", { class: "text-lg text-gray-900 font-medium" }, /* @__PURE__ */ h( RenderAmount, { - value: calc.cashin.credit, + value: cashinCalc.credit, withColor: true, spec: info.fiat_currency_specification } ))))), /* @__PURE__ */ h("div", { class: "sm:col-span-5" }, /* @__PURE__ */ h("dl", { class: "mt-4 space-y-4" }, /* @__PURE__ */ h("div", { class: "justify-between items-center flex " }, /* @__PURE__ */ h("dt", { class: "text-sm text-gray-600" }, /* @__PURE__ */ h(i18n2.Translate, null, "Sending from this bank")), /* @__PURE__ */ h("dd", { class: "text-sm text-gray-900" }, /* @__PURE__ */ h( RenderAmount, { - value: calc.cashout.debit, + value: cashoutCalc.debit, negative: true, withColor: true, spec: info.fiat_currency_specification } - ))), Amounts.isZero(calc.cashout.beforeFee) ? void 0 : /* @__PURE__ */ h("div", { class: "flex items-center justify-between afu" }, /* @__PURE__ */ h("dt", { class: "flex items-center text-sm text-gray-600" }, /* @__PURE__ */ h("span", null, /* @__PURE__ */ h(i18n2.Translate, null, "Converted"))), /* @__PURE__ */ h("dd", { class: "text-sm text-gray-900" }, /* @__PURE__ */ h( + ))), Amounts.isZero(cashoutCalc.beforeFee) ? void 0 : /* @__PURE__ */ h("div", { class: "flex items-center justify-between afu" }, /* @__PURE__ */ h("dt", { class: "flex items-center text-sm text-gray-600" }, /* @__PURE__ */ h("span", null, /* @__PURE__ */ h(i18n2.Translate, null, "Converted"))), /* @__PURE__ */ h("dd", { class: "text-sm text-gray-900" }, /* @__PURE__ */ h( RenderAmount, { - value: calc.cashout.beforeFee, + value: cashoutCalc.beforeFee, spec: info.regional_currency_specification } ))), /* @__PURE__ */ h("div", { class: "flex justify-between items-center border-t-2 afu pt-4" }, /* @__PURE__ */ h("dt", { class: "text-lg text-gray-900 font-medium" }, /* @__PURE__ */ h(i18n2.Translate, null, "Cashout after fee")), /* @__PURE__ */ h("dd", { class: "text-lg text-gray-900 font-medium" }, /* @__PURE__ */ h( RenderAmount, { - value: calc.cashout.credit, + value: cashoutCalc.credit, withColor: true, spec: info.regional_currency_specification } - ))))), calc && status.status === "ok" && Amounts.cmp(status.result.amount, calc.cashout.credit) < 0 ? /* @__PURE__ */ h("div", { class: "p-4" }, /* @__PURE__ */ h(Attention, { title: i18n2.str`Bad configuration`, type: "warning" }, /* @__PURE__ */ h(i18n2.Translate, null, "This configuration allows users to cash out more of what has been cashed in."))) : void 0)), + ))))), cashoutCalc && status.status === "ok" && Amounts.cmp(status.result.amount, cashoutCalc.credit) < 0 ? /* @__PURE__ */ h("div", { class: "p-4" }, /* @__PURE__ */ h(Attention, { title: i18n2.str`Bad configuration`, type: "warning" }, /* @__PURE__ */ h(i18n2.Translate, null, "This configuration allows users to cash out more of what has been cashed in."))) : void 0)), /* @__PURE__ */ h("div", { class: "flex items-center justify-between mt-4 gap-x-6 border-t border-gray-900/10 px-4 py-4" }, /* @__PURE__ */ h( "a", { |