Skip to content

Commit

Permalink
fix: styles for paymentsummary (#2947)
Browse files Browse the repository at this point in the history
* fix: styles for paymentsummary

* fix: tests
  • Loading branch information
reneaaron committed Dec 20, 2023
1 parent 56d4d0d commit 21d5d54
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 38 deletions.
59 changes: 27 additions & 32 deletions src/app/components/PaymentSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,45 @@ import { useSettings } from "~/app/context/SettingsContext";

export type Props = {
amount: string | number;
amountAlt?: string;
description?: string | React.ReactNode;
fiatAmount: string;
};

const PaymentSummary: FC<Props> = ({
amount,
amountAlt,
description,
fiatAmount,
}) => {
const PaymentSummary: FC<Props> = ({ amount, description, fiatAmount }) => {
const { t: tCommon } = useTranslation("common");
const { getFormattedSats } = useSettings();

return (
<dl className="mb-0">
<dt className="text-sm text-gray-500 dark:text-neutral-500">
{tCommon("amount")}
</dt>
<dd className="text-lg text-gray-700 dark:text-neutral-200 flex flex-row justify-between">
<div>{getFormattedSats(amount)}</div>
{!!fiatAmount && (
<span
className="text-gray-500 dark:text-neutral-500"
data-testid="fiat_amount"
>
{" "}
(~{fiatAmount})
</span>
)}
</dd>
{amountAlt && <dd className="text-gray-400">{amountAlt}</dd>}
<dl className="space-y-4">
<div>
<Dt>{tCommon("amount")}</Dt>
<Dd>
<div className="flex flex-row justify-between">
<div>{getFormattedSats(amount)}</div>
{!!fiatAmount && (
<span data-testid="fiat_amount">~{fiatAmount}</span>
)}
</div>
</Dd>
</div>
{!!description && (
<>
<dt className="mt-4 font-medium dark:text-white">
{tCommon("description")}
</dt>
<dd className="text-gray-500 dark:text-neutral-400 break-words whitespace-pre-wrap overflow-y-auto max-h-36">
{description}
</dd>
</>
<div>
<Dt>{tCommon("description")}</Dt>
<Dd>{description}</Dd>
</div>
)}
</dl>
);
};

const Dt = ({ children }: { children: React.ReactNode }) => (
<dt className="text-sm font-medium text-gray-800 dark:text-neutral-200">
{children}
</dt>
);

const Dd = ({ children }: { children: React.ReactNode }) => (
<dd className="text-lg text-gray-600 dark:text-neutral-400">{children}</dd>
);

export default PaymentSummary;
4 changes: 2 additions & 2 deletions src/app/screens/ConfirmKeysend/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen, act } from "@testing-library/react";
import { act, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { MemoryRouter } from "react-router-dom";
import { settingsFixture as mockSettings } from "~/../tests/fixtures/settings";
Expand Down Expand Up @@ -86,7 +86,7 @@ describe("ConfirmKeysend", () => {
});

expect(screen.getByText("21 sats")).toBeInTheDocument();
expect(screen.getByText("(~$0.01)")).toBeInTheDocument();
expect(screen.getByText("~$0.01")).toBeInTheDocument();
expect(screen.queryByText("~$0.05")).not.toBeInTheDocument();

await act(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/app/screens/ConfirmPayment/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen, act } from "@testing-library/react";
import { act, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import lightningPayReq from "bolt11";
import { MemoryRouter } from "react-router-dom";
Expand Down Expand Up @@ -77,7 +77,7 @@ describe("ConfirmPayment", () => {

expect(await screen.findByText("Amount")).toBeInTheDocument();
expect(await screen.findByText("Description")).toBeInTheDocument();
expect(await screen.findByText("(~$0.01)")).toBeInTheDocument();
expect(await screen.findByText("~$0.01")).toBeInTheDocument();
expect(
await screen.findByLabelText("Remember and set a budget")
).toBeInTheDocument();
Expand Down Expand Up @@ -135,7 +135,7 @@ describe("ConfirmPayment", () => {

expect(await screen.findByText("Amount")).toBeInTheDocument();
expect(await screen.findByText("Description")).toBeInTheDocument();
expect(screen.getByText("(~$0.01)")).toBeInTheDocument();
expect(screen.getByText("~$0.01")).toBeInTheDocument();
expect(
await screen.queryByText("Remember and set a budget")
).not.toBeInTheDocument();
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/ConfirmPaymentAsync/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ describe("ConfirmPaymentAsync", () => {

expect(await screen.findByText("Amount")).toBeInTheDocument();
expect(await screen.findByText("Description")).toBeInTheDocument();
expect(await screen.findByText("(~$0.01)")).toBeInTheDocument();
expect(await screen.findByText("~$0.01")).toBeInTheDocument();
});
});

0 comments on commit 21d5d54

Please sign in to comment.