Skip to content

Commit

Permalink
remove unnecessary conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
achowdhry-ripple committed Jan 29, 2025
1 parent e467ceb commit 6394624
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,22 @@ import { TransactionSimpleComponent, TransactionSimpleProps } from '../types'
import { SimpleRow } from '../SimpleRow'
import { convertHexToString } from '../../../../../rippled/lib/utils'

const Simple: TransactionSimpleComponent = (
export const Simple: TransactionSimpleComponent = (
props: TransactionSimpleProps<CredentialAccept>,
) => {
const { t } = useTranslation()
const { data } = props
const { Account, Issuer, CredentialType } = data.instructions
const { Issuer, CredentialType } = data.instructions

return (
<>
{Account && (
<SimpleRow label={t('account')} data-test="account">
{Account}
</SimpleRow>
)}
{Issuer && (
<SimpleRow label={t('issuer')} data-test="issuer">
{Issuer}
</SimpleRow>
)}
{CredentialType && (
<SimpleRow label={t('credential_type')} data-test="credential-type">
{convertHexToString(CredentialType)}
</SimpleRow>
)}
<SimpleRow label={t('issuer')} data-test="issuer">
{Issuer}
</SimpleRow>

<SimpleRow label={t('credential_type')} data-test="credential-type">
{convertHexToString(CredentialType)}
</SimpleRow>
</>
)
}

export { Simple }
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,20 @@ export const TableDetail = ({
instructions,
}: TransactionTableDetailProps<CredentialAccept>) => {
const { t } = useTranslation()
const { Account, Issuer, CredentialType } = instructions
const { Issuer, CredentialType } = instructions
return (
<div className="credentialAccept">
{Account && (
<div className="account">
<span className="label">{t('account')}: </span>
<span className="case-sensitive">{Account}</span>
</div>
)}
{Issuer && (
<div className="issuer">
<span className="label">{t('issuer')}: </span>
<span className="case-sensitive">{Issuer}</span>
</div>
)}
{CredentialType && (
<div className="credential-type">
<span className="label">{t('credential_type')}: </span>
<span className="case-sensitive">
{convertHexToString(CredentialType)}
</span>
</div>
)}
<div className="issuer">
<span className="label">{t('issuer')}: </span>
<span className="case-sensitive">{Issuer}</span>
</div>

<div className="credential-type">
<span className="label">{t('credential_type')}: </span>
<span className="case-sensitive">
{convertHexToString(CredentialType)}
</span>
</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,18 @@ const Simple: TransactionSimpleComponent = (
) => {
const { t } = useTranslation()
const { data } = props
const { Account, Subject, CredentialType, Expiration, URI } =
data.instructions
const { Subject, CredentialType, Expiration, URI } = data.instructions

return (
<>
{Account && (
<SimpleRow label={t('account')} data-test="account">
{Account}
</SimpleRow>
)}
{Subject && (
<SimpleRow label={t('subject')} data-test="subject">
{Subject}
</SimpleRow>
)}
{CredentialType && (
<SimpleRow label={t('credential_type')} data-test="credential-type">
{convertHexToString(CredentialType)}
</SimpleRow>
)}
<SimpleRow label={t('subject')} data-test="subject">
{Subject}
</SimpleRow>

<SimpleRow label={t('credential_type')} data-test="credential-type">
{convertHexToString(CredentialType)}
</SimpleRow>

{Expiration && (
<SimpleRow label={t('expiration')} data-test="expiration">
{Expiration}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,21 @@ export const TableDetail = ({
instructions,
}: TransactionTableDetailProps<CredentialCreate>) => {
const { t } = useTranslation()
const { Account, Subject, CredentialType, Expiration, URI } = instructions
const { Subject, CredentialType, Expiration, URI } = instructions
return (
<div className="credentialCreate">
{Account && (
<div className="account">
<span className="label">{t('account')}: </span>
<span className="case-sensitive">{Account}</span>
</div>
)}
{Subject && (
<div className="issuer">
<span className="label">{t('subject')}: </span>
<span className="case-sensitive">{Subject}</span>
</div>
)}
{CredentialType && (
<div className="credential-type">
<span className="label">{t('credential_type')}: </span>
<span className="case-sensitive">
{convertHexToString(CredentialType)}
</span>
</div>
)}
<div className="issuer">
<span className="label">{t('subject')}: </span>
<span className="case-sensitive">{Subject}</span>
</div>

<div className="credential-type">
<span className="label">{t('credential_type')}: </span>
<span className="case-sensitive">
{convertHexToString(CredentialType)}
</span>
</div>

{Expiration && (
<div className="expiration">
<span className="label">{t('expiration')}: </span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,21 @@ const Simple: TransactionSimpleComponent = (
) => {
const { t } = useTranslation()
const { data } = props
const { Account, Subject, CredentialType, Issuer } = data.instructions
const { Subject, CredentialType, Issuer } = data.instructions

return (
<>
{Account && (
<SimpleRow label={t('account')} data-test="account">
{convertHexToString(Account)}
</SimpleRow>
)}
{Subject && (
<SimpleRow label={t('subject')} data-test="subject">
{convertHexToString(Subject)}
</SimpleRow>
)}
{Issuer && (
<SimpleRow label={t('issuer')} data-test="issuer">
{convertHexToString(Issuer)}
</SimpleRow>
)}
{CredentialType && (
<SimpleRow label={t('credential_type')} data-test="credential-type">
{convertHexToString(CredentialType)}
</SimpleRow>
)}
<SimpleRow label={t('subject')} data-test="subject">
{Subject}
</SimpleRow>

<SimpleRow label={t('issuer')} data-test="issuer">
{Issuer}
</SimpleRow>

<SimpleRow label={t('credential_type')} data-test="credential-type">
{convertHexToString(CredentialType)}
</SimpleRow>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,25 @@ export const TableDetail = ({
instructions,
}: TransactionTableDetailProps<CredentialDelete>) => {
const { t } = useTranslation()
const { Account, Subject, Issuer, CredentialType } = instructions
const { Subject, Issuer, CredentialType } = instructions
return (
<div className="credentialDelete">
{Account && (
<div className="account">
<span className="label">{t('account')}: </span>
<span className="case-sensitive">{Account}</span>
</div>
)}
{Subject && (
<div className="issuer">
<span className="label">{t('subject')}: </span>
<span className="case-sensitive">{Subject}</span>
</div>
)}
{Issuer && (
<div className="issuer">
<span className="label">{t('issuer')}: </span>
<span className="case-sensitive">{Issuer}</span>
</div>
)}
{CredentialType && (
<div className="credential-type">
<span className="label">{t('credential_type')}: </span>
<span className="case-sensitive">
{convertHexToString(CredentialType)}
</span>
</div>
)}
<div className="issuer">
<span className="label">{t('subject')}: </span>
<span className="case-sensitive">{Subject}</span>
</div>

<div className="issuer">
<span className="label">{t('issuer')}: </span>
<span className="case-sensitive">{Issuer}</span>
</div>

<div className="credential-type">
<span className="label">{t('credential_type')}: </span>
<span className="case-sensitive">
{convertHexToString(CredentialType)}
</span>
</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,18 @@ import { useTranslation } from 'react-i18next'
import { type PermissionedDomainDelete } from 'xrpl'

Check failure on line 2 in src/containers/shared/components/Transaction/PermissionedDomainDelete/Simple.tsx

View workflow job for this annotation

GitHub Actions / typescript-check (18.12)

Module '"xrpl"' has no exported member 'PermissionedDomainDelete'.
import { TransactionSimpleComponent, TransactionSimpleProps } from '../types'
import { SimpleRow } from '../SimpleRow'
import { convertHexToString } from '../../../../../rippled/lib/utils'

const Simple: TransactionSimpleComponent = (
props: TransactionSimpleProps<PermissionedDomainDelete>,
) => {
const { t } = useTranslation()
const { data } = props
const { Account, DomainID } = data.instructions
const { DomainID } = data.instructions

return (
<>
{Account && (
<SimpleRow label={t('account')} data-test="account">
{Account}
</SimpleRow>
)}
{DomainID && (
<SimpleRow label={t('domain_id')} data-test="domain-id">
{DomainID}
</SimpleRow>
)}
</>
<SimpleRow label={t('domain_id')} data-test="domain-id">
{DomainID}
</SimpleRow>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ export const TableDetail = ({
instructions,
}: TransactionTableDetailProps<PermissionedDomainDelete>) => {
const { t } = useTranslation()
const { Account, DomainID } = instructions
const { DomainID } = instructions
return (
<div className="permissionedDomainDelete">
{Account && (
<div className="account">
<span className="label">{t('account')}: </span>
<span className="case-sensitive">{Account}</span>
</div>
)}
{DomainID && (
<div className="domainId">
<span className="label">{t('domain_id')}: </span>
<span className="case-sensitive">{DomainID}</span>
</div>
)}
<div className="domainId">
<span className="label">{t('domain_id')}: </span>
<span className="case-sensitive">{DomainID}</span>
</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,28 @@ import { useTranslation } from 'react-i18next'
import { type PermissionedDomainSet } from 'xrpl'

Check failure on line 2 in src/containers/shared/components/Transaction/PermissionedDomainSet/Simple.tsx

View workflow job for this annotation

GitHub Actions / typescript-check (18.12)

Module '"xrpl"' has no exported member 'PermissionedDomainSet'.
import { TransactionSimpleComponent, TransactionSimpleProps } from '../types'
import { SimpleRow } from '../SimpleRow'
import { convertHexToString } from '../../../../../rippled/lib/utils'

const Simple: TransactionSimpleComponent = (
props: TransactionSimpleProps<PermissionedDomainSet>,
) => {
const { t } = useTranslation()
const { data } = props
const { Account, DomainID, AcceptedCredentials } = data.instructions
const { DomainID, AcceptedCredentials } = data.instructions

return (
<>
{Account && (
<SimpleRow label={t('account')} data-test="account">
{Account}
</SimpleRow>
)}
{DomainID && (
<SimpleRow label={t('domain_id')} data-test="domain-id">
{DomainID}
</SimpleRow>
)}
{AcceptedCredentials && (
<SimpleRow
label={t('accepted_credentials')}
data-test="accepted-credentials"
>
{AcceptedCredentials.map((credential) => (
<div>{credential}</div>
))}
</SimpleRow>
)}
<SimpleRow label={t('domain_id')} data-test="domain-id">
{DomainID}
</SimpleRow>

<SimpleRow
label={t('accepted_credentials')}
data-test="accepted-credentials"
>
{AcceptedCredentials.map((credential) => (
<div>{credential}</div>
))}
</SimpleRow>
</>
)
}
Expand Down
Loading

0 comments on commit 6394624

Please sign in to comment.