warn for large amounts

This commit is contained in:
Paul Miller
2023-07-10 17:42:46 -05:00
parent 6c717a7f06
commit dc6cfe695c
2 changed files with 35 additions and 8 deletions

View File

@@ -5,7 +5,9 @@ import {
createResource, createResource,
createSignal, createSignal,
onMount, onMount,
onCleanup onCleanup,
Switch,
Match
} from "solid-js"; } from "solid-js";
import { Button } from "~/components/layout"; import { Button } from "~/components/layout";
import { useMegaStore } from "~/state/megaStore"; import { useMegaStore } from "~/state/megaStore";
@@ -254,6 +256,18 @@ export const AmountEditable: ParentComponent<{
return undefined; return undefined;
}; };
const betaWarning = () => {
const parsed = Number(localSats());
if (isNaN(parsed)) {
return undefined;
}
// If over 4 million sats, warn that it's a beta bro
if (parsed >= 4000000) {
return i18n.t("too_big_for_beta");
}
};
function handleCharacterInput(character: string) { function handleCharacterInput(character: string) {
const isFiatMode = mode() === "fiat"; const isFiatMode = mode() === "fiat";
const inputSanitizer = isFiatMode const inputSanitizer = isFiatMode
@@ -401,7 +415,9 @@ export const AmountEditable: ParentComponent<{
<Show <Show
when={localSats() !== "0"} when={localSats() !== "0"}
fallback={ fallback={
<div class="inline-block font-semibold">{i18n.t("set_amount")}</div> <div class="inline-block font-semibold">
{i18n.t("set_amount")}
</div>
} }
> >
<InlineAmount amount={maxOrLocalSats()} /> <InlineAmount amount={maxOrLocalSats()} />
@@ -472,11 +488,20 @@ export const AmountEditable: ParentComponent<{
/> />
</div> </div>
</div> </div>
<Show when={warningText() && !props.skipWarnings}> <Switch>
<InfoBox accent="blue"> <Match when={betaWarning()}>
{warningText()} <FeesModal /> <InfoBox accent="red">
</InfoBox> {betaWarning()}
</Show> </InfoBox>
</Match>
<Match
when={warningText() && !props.skipWarnings}
>
<InfoBox accent="blue">
{warningText()} <FeesModal />
</InfoBox>
</Match>
</Switch>
<div class="flex justify-center gap-4 my-2"> <div class="flex justify-center gap-4 my-2">
<For <For
each={ each={

View File

@@ -18,5 +18,7 @@ export default {
receive_add_the_sender: "Add the sender for your records", receive_add_the_sender: "Add the sender for your records",
continue: "Continue", continue: "Continue",
receive_bitcoin: "Receive Bitcoin", receive_bitcoin: "Receive Bitcoin",
keep_mutiny_open: "Keep Mutiny open to complete the payment." keep_mutiny_open: "Keep Mutiny open to complete the payment.",
too_big_for_beta:
"That's a lot of sats. You do know Mutiny Wallet is still in beta, yeah?"
}; };