Skip to content

Commit

Permalink
update payment list
Browse files Browse the repository at this point in the history
  • Loading branch information
bgptr committed Aug 13, 2021
1 parent 1a5eaa2 commit 0f066ed
Show file tree
Hide file tree
Showing 25 changed files with 553 additions and 347 deletions.
10 changes: 10 additions & 0 deletions app/actions/LNActions.js
Expand Up @@ -1075,3 +1075,13 @@ export const changeInvoiceFilter = (newFilter) => (dispatch) =>
});
resolve();
});

export const LNWALLET_CHANGE_PAYMENT_FILTER = "LNWALLET_CHANGE_PAYMENT_FILTER";
export const changePaymentFilter = (newFilter) => (dispatch) =>
new Promise((resolve) => {
dispatch({
paymentFilter: newFilter,
type: LNWALLET_CHANGE_PAYMENT_FILTER
});
resolve();
});
32 changes: 21 additions & 11 deletions app/components/modals/LNPaymentModal/LNPaymentModal.jsx
@@ -1,6 +1,6 @@
import Modal from "../Modal";
import { FormattedMessage as T } from "react-intl";
import { CopyableText } from "pi-ui";
import { CopyableText, Message } from "pi-ui";
import styles from "./LNPaymentModal.module.css";
import { Balance, LNPaymentStatus, DetailsTable } from "shared";
import { getPaymentDetails } from "./helpers";
Expand All @@ -10,7 +10,7 @@ const LNPaymentModal = ({ show, onCancelModal, tsDate, payment }) => (
<div
className={styles.closeButton}
onClick={onCancelModal}
data-testid="lninvoice-close-button"
data-testid="lnpayment-close-button"
/>
<div className={styles.title}>
<T id="ln.paymentModal.title" m="Lightning Payment" />
Expand Down Expand Up @@ -41,15 +41,25 @@ const LNPaymentModal = ({ show, onCancelModal, tsDate, payment }) => (
</div>
<Balance amount={payment?.fee} classNameWrapper={styles.amount} />
</div>
<div className={styles.requestCodeLabel}>
<T
id="ln.paymentModal.requestCodeLabel"
m="Lightning Payment Request Code"
/>
</div>
<CopyableText tooltipPlacement="top" id="paymentRequest" truncate={false}>
{payment?.paymentRequest}
</CopyableText>
{payment?.paymentRequest && (
<>
<div className={styles.requestCodeLabel}>
<T
id="ln.paymentModal.requestCodeLabel"
m="Lightning Payment Request Code"
/>
</div>
<CopyableText
tooltipPlacement="top"
id="paymentRequest"
truncate={false}>
{payment.paymentRequest}
</CopyableText>
</>
)}
{payment.paymentError && (
<Message kind="error">{payment.paymentError}</Message>
)}
<DetailsTable
data={getPaymentDetails(payment, tsDate)}
className={styles.details}
Expand Down
15 changes: 15 additions & 0 deletions app/components/modals/LNPaymentModal/helpers.js
Expand Up @@ -10,6 +10,21 @@ export const getPaymentDetails = (payment) => {
}
];

if (payment?.description) {
details.push({
label: <T id="ln.paymentModal.desc" m="Description" />,
value: payment.description
});
}

if (payment?.destination) {
details.push({
label: <T id="ln.paymentModal.destination" m="Destination" />,
value: payment.destination,
truncate: 40
});
}

payment?.htlcsList?.forEach((htlc, index) => {
const response = {
label: (
Expand Down
2 changes: 1 addition & 1 deletion app/components/shared/DetailsTable/DetailsTable.jsx
Expand Up @@ -5,7 +5,7 @@ import { SmallButton } from "buttons";
import { CopyToClipboard, TruncatedText } from "shared";

const ValueField = ({ data }) => {
const { value, copyable, truncate } = data;
const { value, copyable, truncate } = data;
const truncatedText = truncate ? (
<TruncatedText text={value} max={truncate} showTooltip />
) : (
Expand Down
17 changes: 7 additions & 10 deletions app/components/shared/LNPaymentStatus.jsx
@@ -1,10 +1,7 @@
import { StatusTag } from "pi-ui";
import { defineMessages } from "react-intl";
import { useIntl } from "react-intl";
import {
PAYMENT_STATUS_CONFIRMED,
PAYMENT_STATUS_FAILED,
} from "constants";
import { PAYMENT_STATUS_PENDING, PAYMENT_STATUS_FAILED } from "constants";

const messages = defineMessages({
confirmed: {
Expand All @@ -23,18 +20,18 @@ const messages = defineMessages({

const LNPaymentStatus = ({ status }) => {
const intl = useIntl();
return status === PAYMENT_STATUS_CONFIRMED ? (
<StatusTag
type="greenCheck"
text={intl.formatMessage(messages.confirmed)}
/>
return status === PAYMENT_STATUS_PENDING ? (
<StatusTag type="bluePending" text={intl.formatMessage(messages.pending)} />
) : status === PAYMENT_STATUS_FAILED ? (
<StatusTag
type="orangeNegativeCircled"
text={intl.formatMessage(messages.failed)}
/>
) : (
<StatusTag type="bluePending" text={intl.formatMessage(messages.pending)} />
<StatusTag
type="greenCheck"
text={intl.formatMessage(messages.confirmed)}
/>
);
};

Expand Down
@@ -1,5 +1,5 @@
import { FormattedMessage as T } from "react-intl";
import { Balance } from "shared";
import { Balance, TruncatedText } from "shared";
import { DcrInput } from "inputs";
import styles from "./DecodedPayRequest.module.css";

Expand All @@ -24,7 +24,9 @@ const DecodedPayRequest = ({ decoded, sendValue, onSendValueChanged }) => (
<label>
<T id="ln.paymentsTab.destLabel" m="Destination" />
</label>
<div className={styles.destination}>{decoded.destination}</div>
<div className={styles.destination}>
<TruncatedText text={decoded.destination} max={10} />
</div>
</div>
</div>
);
Expand Down
Expand Up @@ -21,9 +21,6 @@
}

.destination {
max-width: 113px;
text-overflow: ellipsis;
overflow: hidden;
font-size: 20px;
line-height: 25px;
color: var(--main-dark-blue);
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion app/components/views/LNPage/SendTab/FailedPayment/index.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions app/components/views/LNPage/SendTab/Payment/Payment.jsx

This file was deleted.

23 changes: 0 additions & 23 deletions app/components/views/LNPage/SendTab/Payment/Payment.module.css

This file was deleted.

1 change: 0 additions & 1 deletion app/components/views/LNPage/SendTab/Payment/index.js

This file was deleted.

Expand Up @@ -20,7 +20,7 @@

.value {
padding-left: 57px;
background-image: var(--ln-invoice-icon);
background-image: var(--minus-small-icon);
background-size: 22px 22px;
background-position: 20px center;
background-repeat: no-repeat;
Expand All @@ -36,10 +36,7 @@
.value .paymentHash {
font-size: 13px;
line-height: 16px;
text-overflow: ellipsis;
overflow: hidden;
color: var(--grey-5);
max-width: 267px;
}

.date {
Expand Down

0 comments on commit 0f066ed

Please sign in to comment.