From 3b7f67d6c691bca6e6dbcd07d2a6fba87720bb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Fri, 5 Jan 2024 00:22:42 +0100 Subject: [PATCH 1/3] refactor: denomination.ts dont use signals here use BigNumber when possible move clockableamount spec to ts --- src/components/ClickableAmount.tsx | 19 +++++++ src/components/Fees.tsx | 9 ++- src/pages/Create.tsx | 35 ++++++++---- src/status/InvoiceSet.tsx | 8 ++- src/status/SwapCreated.tsx | 6 +- src/utils/denomination.ts | 42 +++++++------- src/utils/validation.ts | 3 +- tests/components/ClickableAmount.spec.tsx | 68 +++++++++++++++++++++++ tests/utils/denomination.spec.ts | 13 +++-- 9 files changed, 162 insertions(+), 41 deletions(-) create mode 100644 src/components/ClickableAmount.tsx create mode 100644 tests/components/ClickableAmount.spec.tsx diff --git a/src/components/ClickableAmount.tsx b/src/components/ClickableAmount.tsx new file mode 100644 index 00000000..d1c77f0b --- /dev/null +++ b/src/components/ClickableAmount.tsx @@ -0,0 +1,19 @@ +import { BigNumber } from "bignumber.js"; +import { Show } from "solid-js"; + +import t from "../i18n"; +import { denomination } from "../signals"; +import { formatAmount } from "../utils/denomination"; + +const ClickableAmount = ({ label, onClick, amount }) => { + return ( + <> + {t(label)}: + onClick(amount())} class="btn-small btn-light"> + {formatAmount(BigNumber(amount()), denomination())} + + + ); +}; + +export default ClickableAmount; diff --git a/src/components/Fees.tsx b/src/components/Fees.tsx index 5f890a1d..6f52f49a 100644 --- a/src/components/Fees.tsx +++ b/src/components/Fees.tsx @@ -1,3 +1,4 @@ +import { BigNumber } from "bignumber.js"; import { createEffect } from "solid-js"; import btcSvg from "../assets/btc.svg"; @@ -76,7 +77,7 @@ const Fees = () => {