-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: consolidate transaction operations components
- Loading branch information
Showing
4 changed files
with
61 additions
and
111 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
67 changes: 0 additions & 67 deletions
67
.../app/src/systems/Transaction/components/TxDetails/TxOperationsSimple/TxOperationsList.tsx
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/app/src/systems/Transaction/components/TxDetails/index.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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './TxOperationsSimple'; | ||
export * from './TxHeaderSimple'; | ||
export * from './TxDetails'; | ||
export * from './TxFeeOptions'; |
98 changes: 58 additions & 40 deletions
98
packages/app/src/systems/Transaction/components/TxOperations/TxOperations.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 |
---|---|---|
@@ -1,49 +1,67 @@ | ||
import { Alert, Box } from '@fuel-ui/react'; | ||
import type { AssetData } from '@fuel-wallet/types'; | ||
import type { Operation, TransactionStatus } from 'fuels'; | ||
import type { Maybe } from '~/systems/Core'; | ||
import { Box } from '@fuel-ui/react'; | ||
import type { CategorizedOperations } from '../../types'; | ||
import { TxOperationsGroup } from '../TxDetails/TxOperationsSimple/TxOperationsGroup'; | ||
import { TxOperation } from '../TxDetails/TxOperationsSimple/operations/TxOperation'; | ||
|
||
import { useNetworks } from '~/systems/Network'; | ||
import { TxOperation } from '../TxOperation/TxOperation'; | ||
|
||
export type TxOperationsProps = { | ||
operations?: Operation[]; | ||
status?: Maybe<TransactionStatus>; | ||
isLoading?: boolean; | ||
type TxOperationsListProps = { | ||
operations: CategorizedOperations; | ||
}; | ||
|
||
export function TxOperations({ | ||
operations, | ||
status, | ||
isLoading, | ||
}: TxOperationsProps) { | ||
if (operations?.length === 0) { | ||
return ( | ||
<Alert status="info"> | ||
<Alert.Description> | ||
No operations found in this transaction | ||
</Alert.Description> | ||
</Alert> | ||
); | ||
} | ||
export function TxOperations({ operations }: TxOperationsListProps) { | ||
const { mainOperations, otherRootOperations, intermediateOperations } = | ||
operations; | ||
|
||
return ( | ||
<Box.Stack gap="$0"> | ||
{operations?.map((operation, index) => ( | ||
<TxOperation | ||
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation> | ||
key={index} | ||
operation={operation} | ||
status={status} | ||
isLoading={isLoading} | ||
/> | ||
<> | ||
{/* Main operations (transfers and root contract calls related to current account) */} | ||
{mainOperations.map((operation, index) => ( | ||
<Box.Flex | ||
key={`${operation.type}-${operation.from}-${operation.to}-${index}`} | ||
css={{ | ||
borderRadius: '12px', | ||
flex: 1, | ||
boxSizing: 'border-box', | ||
marginBottom: '16px', | ||
}} | ||
> | ||
<TxOperation operation={operation} showNesting={false} /> | ||
</Box.Flex> | ||
))} | ||
</Box.Stack> | ||
|
||
{/* Other root operations not related to current account */} | ||
<TxOperationsGroup | ||
title="Other Contract Calls" | ||
operations={otherRootOperations} | ||
showNesting={false} | ||
numberLabel="1" | ||
/> | ||
|
||
{/* Intermediate operations with nesting */} | ||
{/* Intermediate opreations exist in the current setup? Wont they all be under the nesting of a root level operation? */} | ||
<TxOperationsGroup | ||
title="Intermediate Operations" | ||
operations={intermediateOperations} | ||
showNesting={true} | ||
numberLabel={otherRootOperations.length ? '2' : '1'} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
TxOperations.Loader = () => ( | ||
<Box.Stack gap="$0"> | ||
<TxOperation.Loader /> | ||
</Box.Stack> | ||
); | ||
TxOperations.Loader = function TxOperationsLoader() { | ||
return ( | ||
<Box.Stack gap="$1"> | ||
{[1, 2].map((i) => ( | ||
<Box | ||
key={i} | ||
css={{ | ||
height: '80px', | ||
backgroundColor: '$gray2', | ||
borderRadius: '$md', | ||
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite', | ||
}} | ||
/> | ||
))} | ||
</Box.Stack> | ||
); | ||
}; |