Skip to content

Commit 6f0ee1e

Browse files
cleanup, formatting, tested'
1 parent 2ce9473 commit 6f0ee1e

File tree

4 files changed

+94
-4
lines changed

4 files changed

+94
-4
lines changed

src/containers/shared/components/Transaction/DepositPreauth/Simple.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export const Simple = ({ data }: TransactionSimpleProps<DepositPreauth>) => {
3535
<SimpleGroup title={`${t('authorize')} ${t('accepted_credentials')}`}>
3636
{AuthorizeCredentials.map((cred, index) => (
3737
<div key={`${cred.Issuer}-${cred.CredentialType}`}>
38+
{index > 0 && (
39+
<div style={{ borderTop: '1px solid #444', margin: '12px 0' }} />
40+
)}
3841
<SimpleRow
3942
label={t('credential_issuer')}
4043
data-testid={`credential-issuer-${index}`}
@@ -58,6 +61,9 @@ export const Simple = ({ data }: TransactionSimpleProps<DepositPreauth>) => {
5861
<SimpleGroup title={`${t('unauthorize')} ${t('accepted_credentials')}`}>
5962
{UnauthorizeCredentials.map((cred, index) => (
6063
<div key={`${cred.Issuer}-${cred.CredentialType}`}>
64+
{index > 0 && (
65+
<div style={{ borderTop: '1px solid #444', margin: '12px 0' }} />
66+
)}
6167
<SimpleRow
6268
label={t('credential_issuer')}
6369
data-testid={`credential-issuer-${index}`}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { useTranslation } from 'react-i18next'
2+
import { TransactionTableDetailProps } from '../types'
3+
import { DepositPreauth } from './types'
4+
import { Account } from '../../Account'
5+
import { convertHexToString } from '../../../../../rippled/lib/utils'
6+
7+
export const TableDetail = ({
8+
instructions,
9+
}: TransactionTableDetailProps<DepositPreauth>) => {
10+
const { t } = useTranslation()
11+
const {
12+
Authorize,
13+
Unauthorize,
14+
AuthorizeCredentials,
15+
UnauthorizeCredentials,
16+
} = instructions
17+
18+
if (Authorize) {
19+
return (
20+
<div className="deposit-preauth">
21+
<span className="label">{t('authorize')}</span>
22+
<Account account={Authorize} />
23+
</div>
24+
)
25+
}
26+
27+
if (Unauthorize) {
28+
return (
29+
<div className="deposit-preauth">
30+
<span className="label">{t('unauthorize')}</span>
31+
<Account account={Unauthorize} />
32+
</div>
33+
)
34+
}
35+
36+
if (AuthorizeCredentials && AuthorizeCredentials.length > 0) {
37+
return (
38+
<div className="deposit-preauth">
39+
<span className="label">{t('authorize')} {t('accepted_credentials')}</span>
40+
<div className="credentials">
41+
{AuthorizeCredentials.map((cred, index) => (
42+
<div key={`${cred.Issuer}-${cred.CredentialType}`} className="credential">
43+
<span className="credential-type">
44+
{convertHexToString(cred.CredentialType)}
45+
</span>
46+
<span className="credential-issuer">
47+
<Account account={cred.Issuer} />
48+
</span>
49+
</div>
50+
))}
51+
</div>
52+
</div>
53+
)
54+
}
55+
56+
if (UnauthorizeCredentials && UnauthorizeCredentials.length > 0) {
57+
return (
58+
<div className="deposit-preauth">
59+
<span className="label">{t('unauthorize')} {t('accepted_credentials')}</span>
60+
<div className="credentials">
61+
{UnauthorizeCredentials.map((cred, index) => (
62+
<div key={`${cred.Issuer}-${cred.CredentialType}`} className="credential">
63+
<span className="credential-type">
64+
{convertHexToString(cred.CredentialType)}
65+
</span>
66+
<span className="credential-issuer">
67+
<Account account={cred.Issuer} />
68+
</span>
69+
</div>
70+
))}
71+
</div>
72+
</div>
73+
)
74+
}
75+
76+
return null
77+
}
78+

src/containers/shared/components/Transaction/DepositPreauth/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import {
66

77
import { Simple } from './Simple'
88
import { Description } from './Description'
9+
import { TableDetail } from './TableDetail'
910
import { parser } from './parser'
1011

1112
export const DepositPreauthTransaction: TransactionMapping = {
1213
Description,
1314
Simple,
15+
TableDetail,
1416
parser,
1517
action: TransactionAction.MODIFY,
1618
category: TransactionCategory.ACCOUNT,

src/containers/shared/components/Transaction/DepositPreauth/parser.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ const transformCredentials = (credentials: any[]): CredentialAuth[] =>
2020
export const parser = (tx: any): DepositPreauth => {
2121
// Handle AuthorizeCredentials (both nested and flat structures)
2222
if (tx.AuthorizeCredentials) {
23-
return {
24-
...tx,
23+
const { Authorize, Unauthorize, ...rest } = tx
24+
const result = {
25+
...rest,
2526
AuthorizeCredentials: transformCredentials(tx.AuthorizeCredentials),
2627
} as DepositPreauth
28+
return result
2729
}
2830

2931
// Handle UnauthorizeCredentials (both nested and flat structures)
3032
if (tx.UnauthorizeCredentials) {
31-
return {
32-
...tx,
33+
const { Authorize, Unauthorize, ...rest } = tx
34+
const result = {
35+
...rest,
3336
UnauthorizeCredentials: transformCredentials(tx.UnauthorizeCredentials),
3437
} as DepositPreauth
38+
return result
3539
}
3640

3741
// For Authorize/Unauthorize fields (string-based), pass through unchanged

0 commit comments

Comments
 (0)