11import { useTranslation } from 'react-i18next'
22import { SimpleRow } from '../SimpleRow'
3+ import { SimpleGroup } from '../SimpleGroup'
34import { TransactionSimpleProps } from '../types'
45import { DepositPreauth , CredentialAuth } from './types'
56import { convertHexToString } from '../../../../../rippled/lib/utils'
67
7- const renderCredentials = ( credentials : CredentialAuth [ ] , t : any ) => {
8- return (
9- < >
10- { credentials . map ( ( cred , index ) => (
11- < div key = { `${ cred . Issuer } -${ cred . CredentialType } ` } >
12- < SimpleRow
13- label = { index === 0 ? t ( 'credential_issuer' ) : '' }
14- data-testid = { `credential-issuer-${ index } ` }
15- >
16- { cred . Issuer }
17- </ SimpleRow >
18- < SimpleRow
19- label = { index === 0 ? t ( 'credential_type' ) : '' }
20- data-testid = { `credential-type-${ index } ` }
21- >
22- { convertHexToString ( cred . CredentialType ) }
23- </ SimpleRow >
24- </ div >
25- ) ) }
26- </ >
27- )
28- }
29-
308export const Simple = ( { data } : TransactionSimpleProps < DepositPreauth > ) => {
319 const { t } = useTranslation ( )
3210 const { Authorize, Unauthorize, AuthorizeCredentials, UnauthorizeCredentials } = data . instructions
@@ -49,23 +27,47 @@ export const Simple = ({ data }: TransactionSimpleProps<DepositPreauth>) => {
4927
5028 if ( AuthorizeCredentials && AuthorizeCredentials . length > 0 ) {
5129 return (
52- < >
53- < SimpleRow label = { t ( 'authorize' ) } data-testid = "authorize-credentials-label" >
54- { t ( 'accepted_credentials' ) }
55- </ SimpleRow >
56- { renderCredentials ( AuthorizeCredentials , t ) }
57- </ >
30+ < SimpleGroup title = { `${ t ( 'authorize' ) } ${ t ( 'accepted_credentials' ) } ` } >
31+ { AuthorizeCredentials . map ( ( cred , index ) => (
32+ < div key = { `${ cred . Issuer } -${ cred . CredentialType } ` } >
33+ < SimpleRow
34+ label = { t ( 'credential_issuer' ) }
35+ data-testid = { `credential-issuer-${ index } ` }
36+ >
37+ { cred . Issuer }
38+ </ SimpleRow >
39+ < SimpleRow
40+ label = { t ( 'credential_type' ) }
41+ data-testid = { `credential-type-${ index } ` }
42+ >
43+ { convertHexToString ( cred . CredentialType ) }
44+ </ SimpleRow >
45+ </ div >
46+ ) ) }
47+ </ SimpleGroup >
5848 )
5949 }
6050
6151 if ( UnauthorizeCredentials && UnauthorizeCredentials . length > 0 ) {
6252 return (
63- < >
64- < SimpleRow label = { t ( 'unauthorize' ) } data-testid = "unauthorize-credentials-label" >
65- { t ( 'accepted_credentials' ) }
66- </ SimpleRow >
67- { renderCredentials ( UnauthorizeCredentials , t ) }
68- </ >
53+ < SimpleGroup title = { `${ t ( 'unauthorize' ) } ${ t ( 'accepted_credentials' ) } ` } >
54+ { UnauthorizeCredentials . map ( ( cred , index ) => (
55+ < div key = { `${ cred . Issuer } -${ cred . CredentialType } ` } >
56+ < SimpleRow
57+ label = { t ( 'credential_issuer' ) }
58+ data-testid = { `credential-issuer-${ index } ` }
59+ >
60+ { cred . Issuer }
61+ </ SimpleRow >
62+ < SimpleRow
63+ label = { t ( 'credential_type' ) }
64+ data-testid = { `credential-type-${ index } ` }
65+ >
66+ { convertHexToString ( cred . CredentialType ) }
67+ </ SimpleRow >
68+ </ div >
69+ ) ) }
70+ </ SimpleGroup >
6971 )
7072 }
7173
0 commit comments