-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove connected react router (#627)
BREAKING CHANGE : location saga was moved to a hook "useManaFiatGatewayPurchase"
- Loading branch information
Melisa Anabella Rossi
authored
Jun 11, 2024
1 parent
2ae6c54
commit 73d0313
Showing
8 changed files
with
37 additions
and
291 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.
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
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,37 @@ | ||
import { Network } from '@dcl/schemas' | ||
import { NetworkGatewayType } from 'decentraland-ui' | ||
import { useHistory, useLocation } from 'react-router' | ||
import { MoonPayTransactionStatus } from '../modules/gateway/moonpay/types' | ||
import { useDispatch } from 'react-redux' | ||
import { manaFiatGatewayPurchaseCompleted } from '../modules/gateway' | ||
|
||
export default function useManaFiatGatewayPurchase() { | ||
const location = useLocation() | ||
const query = new URLSearchParams(location.search) | ||
const network = query.get('network') as Network | ||
const gateway = query.get('gateway') as NetworkGatewayType | ||
const transactionId = query.get('transactionId') as string | ||
const transactionStatus = query.get( | ||
'transactionStatus' | ||
) as MoonPayTransactionStatus | ||
const history = useHistory() | ||
const dispatch = useDispatch() | ||
|
||
if (transactionId && transactionStatus && network && gateway) { | ||
const queryParams = new URLSearchParams(query) | ||
const params = ['transactionId', 'transactionStatus', 'network', 'gateway'] | ||
|
||
params.forEach(param => queryParams.delete(param)) | ||
|
||
history.replace(`${location.pathname}?${queryParams.toString()}`) | ||
|
||
dispatch( | ||
manaFiatGatewayPurchaseCompleted( | ||
network, | ||
gateway, | ||
transactionId, | ||
transactionStatus | ||
) | ||
) | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.