-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'frontend-lightning-transactions' into staging-ln
- Loading branch information
Showing
11 changed files
with
338 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
frontends/web/src/routes/lightning/components/action-buttons.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.actionsContainer { | ||
--size-default: 14px; | ||
display: flex; | ||
flex-grow: 1; | ||
flex-shrink: 0; | ||
flex-wrap: nowrap; | ||
justify-content: flex-end; | ||
/* margin-top: var(--space-half); */ | ||
padding-bottom: 0; | ||
} | ||
|
||
.receive, | ||
.send { | ||
background-color: var(--color-blue); | ||
border-radius: 2px; | ||
color: var(--color-alt); | ||
display: inline-block; | ||
font-size: var(--size-default); | ||
height: calc(var(--item-height) / 1.5); | ||
line-height: calc(var(--item-height) / 1.5); | ||
min-width: calc(var(--item-height) * 2); | ||
padding: 0 var(--space-half); | ||
text-align: center; | ||
text-decoration: none; | ||
transition: background-color ease-out 0.2s; | ||
width: calc(var(--item-height) * 2); | ||
will-change: background-color; | ||
} | ||
|
||
.receive, | ||
.send { | ||
margin-left: var(--space-quarter); | ||
} | ||
|
||
.buy:hover, | ||
.receive:hover, | ||
.send:not(.disabled):hover { | ||
background-color: var(--color-lightblue); | ||
} | ||
|
||
.send.disabled { | ||
cursor: default; | ||
opacity: 0.4; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
.send, | ||
.receive { | ||
font-size: var(--size-small); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
frontends/web/src/routes/lightning/components/payment-details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/** | ||
* Copyright 2024 Shift Crypto AG | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import type { Payment as IPayment, LnPaymentDetails } from '@/api/lightning'; | ||
import { Dialog } from '@/components/dialog/dialog'; | ||
import { FiatConversion } from '@/components/rates/rates'; | ||
import { TxDetail } from '@/components/transactions/components/detail'; | ||
import { TxDateDetail } from '@/components/transactions/components/date'; | ||
import { TxDetailCopyableValues } from '@/components/transactions/components/address-or-txid'; | ||
import { getTxSign } from '@/components/transactions/utils'; | ||
import { toSat } from '@/utils/conversion'; | ||
import styles from '@/components/transactions/components/details.module.css'; | ||
|
||
type TTxDetailsDialog = { | ||
open: boolean; | ||
onClose: () => void; | ||
payment: IPayment; | ||
sign: string; | ||
} | ||
|
||
export const PaymentDetailsDialog = ({ | ||
open, | ||
onClose, | ||
payment, | ||
sign, | ||
}: TTxDetailsDialog) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
title={t('transaction.details.title')} | ||
onClose={onClose} | ||
slim | ||
medium> | ||
{payment && ( | ||
<> | ||
<TxDetail label="Memo"> | ||
{payment.description} | ||
</TxDetail> | ||
<TxDateDetail | ||
time={new Date(payment.paymentTime * 1000).toString()} | ||
/> | ||
<TxDetail label="Amount"> | ||
{toSat(payment.amountMsat)} | ||
{' '} | ||
sat | ||
</TxDetail> | ||
<TxDetail label={t('transaction.details.fiat')}> | ||
<span className={styles.fiat}> | ||
<FiatConversion | ||
amount={{ | ||
amount: `${toSat(payment.amountMsat)}`, | ||
unit: 'sat', | ||
estimated: false | ||
}} | ||
sign={sign} | ||
noAction | ||
/> | ||
</span> | ||
</TxDetail> | ||
<TxDetail label="fee"> | ||
{payment.feeMsat} | ||
{' '} | ||
msat | ||
</TxDetail> | ||
<TxDetail label="type"> | ||
{payment.paymentType} | ||
</TxDetail> | ||
<TxDetail label="status"> | ||
{payment.status} | ||
</TxDetail> | ||
{ payment.paymentType !== 'closedChannel' && ( | ||
<TxDetailCopyableValues | ||
key="paymentPreimage" | ||
label="paymentPreimage" | ||
values={[ | ||
(payment.details.data as LnPaymentDetails).paymentPreimage | ||
]} | ||
/> | ||
)} | ||
{ payment.paymentType !== 'closedChannel' && ( | ||
<TxDetailCopyableValues | ||
key="paymentHash" | ||
label="paymentHash" | ||
values={[ | ||
(payment.details.data as LnPaymentDetails).paymentHash | ||
]} | ||
/> | ||
)} | ||
</> | ||
)} | ||
</Dialog> | ||
); | ||
}; | ||
|
||
type TTransactionDetails = { | ||
id: string | null; | ||
payment?: IPayment; | ||
onClose: () => void; | ||
} | ||
|
||
export const PaymentDetails = ({ | ||
id, | ||
payment, | ||
onClose, | ||
}: TTransactionDetails) => { | ||
const [open, setOpen] = useState(false); | ||
|
||
useEffect(() => { | ||
if (id) { | ||
setOpen(true); | ||
} | ||
}, [id]); | ||
|
||
if (!payment) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<PaymentDetailsDialog | ||
open={open} | ||
onClose={() => { | ||
setOpen(false); | ||
onClose(); | ||
}} | ||
payment={payment} | ||
sign={getTxSign(payment.paymentType === 'received' ? 'receive' : 'send')} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.