Skip to content

Commit

Permalink
show pending info when payment timed out
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed Nov 10, 2023
1 parent dd12f55 commit ec3adb0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
Binary file added src/assets/icons/megaclock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/components/successfail/MegaClock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import megaclock from "~/assets/icons/megaclock.png";

export function MegaClock() {
return (
<img
src={megaclock}
alt="fail"
class="mx-auto w-1/2 max-w-[30vh] flex-shrink"
/>
);
}
1 change: 1 addition & 0 deletions src/components/successfail/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./MegaCheck";
export * from "./MegaEx";
export * from "./MegaClock";
export * from "./SuccessModal";
5 changes: 4 additions & 1 deletion src/i18n/en/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ export default {
"Amount requested, {{amount}} SATS, does not equal amount set.",
error_clipboard: "Clipboard not supported",
error_keysend: "Keysend failed",
error_LNURL: "LNURL Pay failed"
error_LNURL: "LNURL Pay failed",
payment_pending: "Payment pending",
payment_pending_description:
"It's taking a while, but it's possible this payment may still go through. Please check 'Activity' for the current status."
},
feedback: {
header: "Give us feedback!",
Expand Down
40 changes: 31 additions & 9 deletions src/routes/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
InfoBox,
LargeHeader,
MegaCheck,
MegaClock,
MegaEx,
MutinyWalletGuard,
NavBar,
Expand Down Expand Up @@ -198,6 +199,30 @@ function DestinationShower(props: {
);
}

function Failure(props: { reason: string }) {
const i18n = useI18n();

return (
<Switch>
<Match when={props.reason === "Payment timed out."}>
<MegaClock />
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
{i18n.t("send.payment_pending")}
</h1>
<InfoBox accent="white">
{i18n.t("send.payment_pending_description")}
</InfoBox>
</Match>
<Match when={true}>
<MegaEx />
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
{props.reason}
</h1>
</Match>
</Switch>
);
}

export default function Send() {
const [state, actions] = useMegaStore();
const navigate = useNavigate();
Expand Down Expand Up @@ -635,15 +660,12 @@ export default function Send() {
>
<Switch>
<Match when={sentDetails()?.failure_reason}>
<MegaEx />
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
{sentDetails()?.amount
? source() === "onchain"
? i18n.t("send.payment_initiated")
: i18n.t("send.payment_sent")
: sentDetails()?.failure_reason}
</h1>
{/*TODO: add failure hint logic for different failure conditions*/}
<Failure
reason={
sentDetails()?.failure_reason ||
"Payment failed for an unknown reason"
}
/>
</Match>
<Match when={true}>
<Show when={detailsId() && detailsKind()}>
Expand Down

0 comments on commit ec3adb0

Please sign in to comment.