-
Notifications
You must be signed in to change notification settings - Fork 159
fix: unify order summary #6773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shoom3301
wants to merge
26
commits into
develop
Choose a base branch
from
refactor/order-summary-2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: unify order summary #6773
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
10de804
chore: mark places where order summary is in use
shoom3301 405295e
refactor: simplify createActivityDescriptor
shoom3301 448ac0e
refactor(ActivityDetails): replace order.summary with computeOrderSum…
shoom3301 9fad34a
refactor(RequestCancellationModal): extract styled el to another file
shoom3301 533ac14
refactor(CancellationModal): use computeOrderSummary instead of order…
shoom3301 c7962be
refactor(RequestCancellationModal): get rid of render functions
shoom3301 cf33725
refactor: simplify computeOrderSummary
shoom3301 1ebc832
refactor: extract useGetSerializedBridgeOrder
shoom3301 0c70318
feat: support all kinds of order in computeOrderSummary
shoom3301 8f4a80e
feat: compute order summary taking bridge into account
shoom3301 9334831
fix: fix canceled bridge order displaying
shoom3301 f318fb9
chore: fix tests
shoom3301 50d1c28
chore: add tests for bridging orders
shoom3301 f4b727a
chore: simplify types
shoom3301 b9b5450
chore: remove excessive computeOrderSummary call
shoom3301 94df4d2
refactor: replace computeOrderSummary with OrderSummary
shoom3301 374b0b3
fix: generalize OrderNotification for any type of order
shoom3301 cbafb71
chore: remove dead code
shoom3301 279b507
Merge branch 'develop' into refactor/order-summary
shoom3301 6e0827c
Merge branch 'refactor/order-summary' of https://github.com/cowprotoc…
shoom3301 75a02ed
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 93b8d91
Merge branch 'refactor/order-summary-1' of https://github.com/cowprot…
shoom3301 19c9474
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 9771cea
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 f8962f8
chore: update i18n
shoom3301 f1f7a1a
chore: delete irrelevant tests
shoom3301 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
4 changes: 3 additions & 1 deletion
4
apps/cowswap-frontend/src/common/pure/CancellationModal/types.ts
This file contains hidden or 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
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,57 +5,26 @@ import { ExternalLink } from '@cowprotocol/ui' | |
|
|
||
| import { t } from '@lingui/core/macro' | ||
| import { Trans } from '@lingui/react/macro' | ||
| import { useBridgeOrderData } from 'entities/bridgeOrders' | ||
|
|
||
| import { getUiOrderType } from 'utils/orderUtils/getUiOrderType' | ||
| import type { OrderSummaryTemplateProps } from 'common/pure/OrderSummary/summaryTemplates' | ||
|
|
||
| import { OrderNotification } from '../OrderNotification' | ||
| import { mapBridgingResultToOrderInfo } from '../OrderNotification/utils' | ||
|
|
||
| import type { OrderSummaryTemplateProps } from '../../pure/OrderSummary/summaryTemplates' | ||
|
|
||
| function summaryTemplate({ | ||
| inputAmount, | ||
| outputAmount, | ||
| srcChainData, | ||
| dstChainData, | ||
| }: OrderSummaryTemplateProps): ReactNode { | ||
| return ( | ||
| <> | ||
| <Trans>Sell</Trans> {inputAmount}{' '} | ||
| {srcChainData && ( | ||
| <> | ||
| ({srcChainData.label}) <Trans>for a total of</Trans> {outputAmount}{' '} | ||
| {dstChainData && <> ({dstChainData.label})</>} | ||
| </> | ||
| )} | ||
| </> | ||
| ) | ||
| } | ||
|
|
||
| interface BridgingSuccessNotificationProps { | ||
| payload: OnBridgingSuccessPayload | ||
| } | ||
|
|
||
| export function BridgingSuccessNotification({ payload }: BridgingSuccessNotificationProps): ReactNode { | ||
| const { chainId, order } = payload | ||
| const bridgingOrder = useBridgeOrderData(order.uid) | ||
|
|
||
| if (!bridgingOrder) return null | ||
|
|
||
| const orderInfo = mapBridgingResultToOrderInfo(payload, bridgingOrder) | ||
|
|
||
| return ( | ||
| <OrderNotification | ||
| title={<Trans>Bridging succeeded</Trans>} | ||
| actionTitle={t`Bridge`} | ||
| skipExplorerLink | ||
| chainId={chainId} | ||
| orderInfo={orderInfo} | ||
| customTemplate={summaryTemplate} | ||
| orderType={getUiOrderType(order)} | ||
| orderUid={order.uid} | ||
| receiver={bridgingOrder.recipient} | ||
| messageType={ToastMessageType.ORDER_FULFILLED} | ||
| bottomContent={ | ||
| payload.explorerUrl ? ( | ||
|
|
@@ -70,3 +39,22 @@ export function BridgingSuccessNotification({ payload }: BridgingSuccessNotifica | |
| /> | ||
| ) | ||
| } | ||
|
|
||
| function summaryTemplate({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can improve this component or its documentation so that it's clear if |
||
| inputAmount, | ||
| outputAmount, | ||
| srcChainData, | ||
| dstChainData, | ||
| }: OrderSummaryTemplateProps): ReactNode { | ||
| return ( | ||
| <> | ||
| <Trans>Sell</Trans> {inputAmount}{' '} | ||
| {srcChainData && ( | ||
| <> | ||
| ({srcChainData.label}) <Trans>for a total of</Trans> {outputAmount}{' '} | ||
| {dstChainData && <> ({dstChainData.label})</>} | ||
| </> | ||
| )} | ||
| </> | ||
| ) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computeOrderSummarywas never called here, lol