Files
explore/ui/tx/details/TxDetailsTacOperation.tsx

61 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React from 'react';
import type * as tac from '@luxfi/tac-operation-lifecycle-types';
import { getTacOperationStage } from 'lib/operations/tac';
import { Tag } from '@luxfi/ui/tag';
import * as DetailedInfo from 'ui/shared/DetailedInfo/DetailedInfo';
import OperationEntity from 'ui/shared/entities/operation/OperationEntity';
import TacOperationStatus from 'ui/shared/statusTag/TacOperationStatus';
interface Props {
tacOperations: Array<tac.OperationDetails>;
isLoading: boolean;
txHash: string;
}
const TxDetailsTacOperation = ({ tacOperations, isLoading, txHash }: Props) => {
const hasManyItems = tacOperations.length > 1;
const [ hasScroll, setHasScroll ] = React.useState(false);
return (
<>
<DetailedInfo.ItemLabel
hint={ `Hash${ hasManyItems ? 'es' : '' } of the cross‑chain operation${ hasManyItems ? 's' : '' } that this transaction is part of` }
isLoading={ isLoading }
hasScroll={ hasScroll }
>
Source operation{ hasManyItems ? 's' : '' }
</DetailedInfo.ItemLabel>
<DetailedInfo.ItemValueWithScroll
gradientHeight={ 48 }
onScrollVisibilityChange={ setHasScroll }
>
{ tacOperations.map((tacOperation) => {
const tags = [
...(getTacOperationStage(tacOperation, txHash) || []),
];
return (
<div key={ tacOperation.operation_id }>
<OperationEntity
id={ tacOperation.operation_id }
type={ tacOperation.type }
isLoading={ isLoading }
/>
{ tags.length > 0 && (
<div>
<TacOperationStatus status={ tacOperation.type } isLoading={ isLoading }/>
{ tags.map((tag) => <Tag key={ tag } loading={ isLoading } className="shrink-0">{ tag }</Tag>) }
</div>
) }
</div>
);
}) }
</DetailedInfo.ItemValueWithScroll>
</>
);
};
export default React.memo(TxDetailsTacOperation);