-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
349 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
152 changes: 152 additions & 0 deletions
152
ui/pages/bridge/quotes/bridge-quote-details-modal.stories.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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import React from 'react'; | ||
import { Provider, useSelector } from 'react-redux'; | ||
import configureStore from '../../../store/store'; | ||
import { BridgeQuotesModal } from './bridge-quotes-modal'; | ||
import { createBridgeMockStore } from '../../../../test/jest/mock-store'; | ||
import mockBridgeQuotesErc20Erc20 from '../../../../test/data/bridge/mock-quotes-erc20-erc20.json'; | ||
import { BridgeQuoteDetailsModal } from './bridge-quote-details-modal'; | ||
import { getBridgeQuotes } from '../../../ducks/bridge/selectors'; | ||
import { Modal, ModalOverlay } from '../../../components/component-library'; | ||
|
||
// export const NoTokenPricesAvailableStory = () => { | ||
// return <BridgeQuotesModal onClose={() => {}} isOpen={true} />; | ||
// }; | ||
// NoTokenPricesAvailableStory.storyName = 'Token Prices Not Available'; | ||
// NoTokenPricesAvailableStory.decorators = [ | ||
// (story) => ( | ||
// <Provider | ||
// store={configureStore( | ||
// createBridgeMockStore({}, {}, { quotes: mockBridgeQuotesErc20Erc20 }), | ||
// )} | ||
// > | ||
// {story()} | ||
// </Provider> | ||
// ), | ||
// ]; | ||
|
||
export const DefaultStory = () => { | ||
const { activeQuote } = useSelector(getBridgeQuotes); | ||
return activeQuote ? ( | ||
<BridgeQuoteDetailsModal | ||
onBack={() => {}} | ||
onSelect={() => {}} | ||
expandedQuote={activeQuote} | ||
/> | ||
) : null; | ||
}; | ||
|
||
const storybook = { | ||
title: 'Pages/Bridge/BridgeQuoteDetailsModal', | ||
component: DefaultStory, | ||
}; | ||
|
||
DefaultStory.storyName = 'Default'; | ||
DefaultStory.decorators = [ | ||
(Story) => ( | ||
<Modal isOpen={true} className="quotes-modal" onClose={() => {}}> | ||
<ModalOverlay /> | ||
<Provider | ||
store={configureStore( | ||
createBridgeMockStore( | ||
{}, | ||
{ | ||
toNativeExchangeRate: 1, | ||
toTokenExchangeRate: 0.99, | ||
}, | ||
{ quotes: mockBridgeQuotesErc20Erc20 }, | ||
{ | ||
currencyRates: { | ||
ETH: { conversionRate: 2514.5 }, | ||
}, | ||
marketData: { | ||
'0x1': { | ||
['0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85']: { | ||
price: 0.00039762010419237126, | ||
contractPercentChange1d: 0.004, | ||
priceChange1d: 0.00004, | ||
}, | ||
}, | ||
}, | ||
}, | ||
), | ||
)} | ||
> | ||
<Story /> | ||
</Provider> | ||
</Modal> | ||
), | ||
]; | ||
|
||
// export const PositiveArbitrage = () => { | ||
// return <BridgeQuotesModal onClose={() => {}} isOpen={true} />; | ||
// }; | ||
// PositiveArbitrage.decorators = [ | ||
// (story) => ( | ||
// <Provider | ||
// store={configureStore( | ||
// createBridgeMockStore( | ||
// {}, | ||
// { | ||
// toNativeExchangeRate: 1, | ||
// toTokenExchangeRate: 2.1, | ||
// }, | ||
// { quotes: mockBridgeQuotesErc20Erc20 }, | ||
// { | ||
// currencyRates: { | ||
// ETH: { conversionRate: 2514.5 }, | ||
// }, | ||
// marketData: { | ||
// '0x1': { | ||
// ['0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85']: { | ||
// price: 0.00039762010419237126, | ||
// contractPercentChange1d: 0.004, | ||
// priceChange1d: 0.00004, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// ), | ||
// )} | ||
// > | ||
// {story()} | ||
// </Provider> | ||
// ), | ||
// ]; | ||
|
||
// export const QuoteDetails = () => { | ||
// return <BridgeQuotesModal onClose={() => {}} isOpen={true} />; | ||
// }; | ||
// QuoteDetails.decorators = [ | ||
// (story) => ( | ||
// <Provider | ||
// store={configureStore( | ||
// createBridgeMockStore( | ||
// {}, | ||
// { | ||
// toNativeExchangeRate: 1, | ||
// toTokenExchangeRate: 2.1, | ||
// }, | ||
// { quotes: mockBridgeQuotesErc20Erc20 }, | ||
// { | ||
// currencyRates: { | ||
// ETH: { conversionRate: 2514.5 }, | ||
// }, | ||
// marketData: { | ||
// '0x1': { | ||
// ['0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85']: { | ||
// price: 0.00039762010419237126, | ||
// contractPercentChange1d: 0.004, | ||
// priceChange1d: 0.00004, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// ), | ||
// )} | ||
// > | ||
// {story()} | ||
// </Provider> | ||
// ), | ||
// ]; | ||
|
||
export default storybook; |
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React from 'react'; | ||
import { | ||
Box, | ||
Button, | ||
ModalContent, | ||
ModalHeader, | ||
Text, | ||
} from '../../../components/component-library'; | ||
import { Footer } from '../../../components/multichain/pages/page'; | ||
import { | ||
TextAlign, | ||
TextVariant, | ||
} from '../../../helpers/constants/design-system'; | ||
import { useI18nContext } from '../../../hooks/useI18nContext'; | ||
import { QuoteMetadata, QuoteResponse } from '../types'; | ||
import { QuoteInfoRow } from './quote-info-row'; | ||
|
||
export const BridgeQuoteDetailsModal = ({ | ||
onBack, | ||
onSelect, | ||
expandedQuote, | ||
}: { | ||
onBack: () => void; | ||
onSelect: () => void; | ||
expandedQuote: QuoteResponse & QuoteMetadata; | ||
}) => { | ||
const t = useI18nContext(); | ||
|
||
const { | ||
quote, | ||
estimatedProcessingTimeInSeconds, | ||
swapRate, | ||
sentAmount, | ||
totalNetworkFee, | ||
toTokenAmount, | ||
} = expandedQuote; | ||
|
||
return ( | ||
<ModalContent modalDialogProps={{ padding: 0 }}> | ||
<ModalHeader onBack={onBack}> | ||
<Text variant={TextVariant.headingSm} textAlign={TextAlign.Center}> | ||
{t('swapQuoteDetails')} | ||
</Text> | ||
</ModalHeader> | ||
<Box className="quotes-modal__quote-details"> | ||
<div className="quote-detail-group"> | ||
<QuoteInfoRow label={t('source')} description={quote.bridges[0]} /> | ||
<QuoteInfoRow label={t('quoteRate')} description={`${swapRate}`} /> | ||
<QuoteInfoRow | ||
label={t('estimatedTime')} | ||
description={`${estimatedProcessingTimeInSeconds}`} | ||
/> | ||
</div> | ||
<hr /> | ||
<div className="quote-detail-group"> | ||
<QuoteInfoRow label={t('swapAmount')} description={`${sentAmount}`} /> | ||
<QuoteInfoRow | ||
label={t('includedFees')} | ||
description={'MM fee'} | ||
tooltipText="tooltip" | ||
/> | ||
<QuoteInfoRow | ||
label={t('networkFee')} | ||
description={`${totalNetworkFee}`} | ||
tooltipText="tooltip" | ||
/> | ||
<QuoteInfoRow | ||
label={t('totalPaid')} | ||
description={'sentAmount + networkFee'} | ||
/> | ||
</div> | ||
<hr /> | ||
<div className="quote-detail-group"> | ||
<QuoteInfoRow | ||
label={t('totalReceived')} | ||
description={`${toTokenAmount}`} | ||
/> | ||
</div> | ||
</Box> | ||
<Footer> | ||
<Button | ||
className="quotes-modal__quote-details__use-quote-button" | ||
data-testid="use-quote-button" | ||
onClick={onSelect} | ||
disabled={false} | ||
> | ||
{t('bridgeUseQuote')} | ||
</Button> | ||
</Footer> | ||
</ModalContent> | ||
); | ||
}; |
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
Oops, something went wrong.