Skip to content

Commit

Permalink
Solving receipt undesired arrow on header (#283)
Browse files Browse the repository at this point in the history
* Fixing transaction receipt for internal transfers

* Solving receipt undesired arrow on header
  • Loading branch information
hbulgarini authored Sep 12, 2021
1 parent e74100a commit 05a1771
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/components/TransactionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import React from 'react';

import { Box } from '@material-ui/core';
import { IconTxStatus } from './Icons';
import { TransactionStatusEnum } from '../types/transactionTypes';
import { useGUIContext } from '../contexts/GUIContextProvider';
import { TransactionStatusEnum, TransactionTypes } from '../types/transactionTypes';

interface Props {
status: TransactionStatusEnum;
Expand All @@ -36,10 +35,8 @@ const getType = (type: string | undefined) => {
};

const TransactionHeader = ({ type, status, sourceChain, targetChain }: Props) => {
const { isBridged } = useGUIContext();

let header = ` ${sourceChain} -> ${targetChain}`;
if (!isBridged) {
if (type === TransactionTypes.INTERNAL_TRANSFER) {
header = sourceChain;
}

Expand Down
17 changes: 11 additions & 6 deletions src/components/TransactionStatusMock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
import React, { useEffect, useState } from 'react';

import { useSourceTarget } from '../contexts/SourceTargetContextProvider';
import { Step, TransactionStatusEnum } from '../types/transactionTypes';
import { Step, TransactionStatusEnum, TransactionTypes } from '../types/transactionTypes';
import TransactionReceipt from './TransactionReceipt';
import TransactionSwitchTab from './TransactionSwitchTab';
import { createEmptySteps } from '../util/transactions/';
import { createEmptyInternalSteps, createEmptySteps } from '../util/transactions/';
import { useTransactionContext } from '../contexts/TransactionContext';
import { useGUIContext } from '../contexts/GUIContextProvider';
interface Props {
type?: string;
}

const TransactionStatusMock = ({ type }: Props) => {
const [steps, setSteps] = useState<Array<Step>>([]);

const { isBridged } = useGUIContext();
const {
sourceChainDetails: { chain: sourceChain },
targetChainDetails: { chain: targetChain }
Expand All @@ -37,8 +38,12 @@ const TransactionStatusMock = ({ type }: Props) => {
const { payloadHex, transactionDisplayPayload } = useTransactionContext();

useEffect(() => {
setSteps(createEmptySteps(sourceChain, targetChain));
}, [sourceChain, targetChain]);
if (isBridged) {
setSteps(createEmptySteps(sourceChain, targetChain));
} else {
setSteps(createEmptyInternalSteps(sourceChain));
}
}, [isBridged, sourceChain, targetChain]);

return (
<TransactionSwitchTab
Expand All @@ -51,7 +56,7 @@ const TransactionStatusMock = ({ type }: Props) => {
>
<TransactionReceipt
steps={steps}
type={type}
type={isBridged ? type : TransactionTypes.INTERNAL_TRANSFER}
status={TransactionStatusEnum.NOT_STARTED}
sourceChain={sourceChain}
targetChain={targetChain}
Expand Down

0 comments on commit 05a1771

Please sign in to comment.