-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/ID-1897-improve-magic-session-manage…
…ment
- Loading branch information
Showing
17 changed files
with
532 additions
and
262 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
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
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
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
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
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
94 changes: 94 additions & 0 deletions
94
packages/checkout/widgets-lib/src/widgets/purchase/components/WithCard.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,94 @@ | ||
import { useContext, useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { WalletProviderRdns } from '@imtbl/checkout-sdk'; | ||
import { PurchaseContext } from '../context/PurchaseContext'; | ||
import { TransakIframe } from '../../../components/Transak/TransakIframe'; | ||
import { TransakNFTData } from '../../../components/Transak/TransakTypes'; | ||
import { useProvidersContext } from '../../../context/providers-context/ProvidersContext'; | ||
|
||
export interface WithCardProps { | ||
onInit?: (data: Record<string, unknown>) => void; | ||
onOpen?: (data: Record<string, unknown>) => void; | ||
onOrderCreated?: (data: Record<string, unknown>) => void; | ||
onOrderProcessing?: (data: Record<string, unknown>) => void; | ||
onOrderCompleted?: (data: Record<string, unknown>) => void; | ||
onOrderFailed?: (data: Record<string, unknown>) => void; | ||
} | ||
|
||
export function WithCard(props: WithCardProps) { | ||
const { t } = useTranslation(); | ||
const { | ||
onInit, | ||
onOpen, | ||
onOrderCreated, | ||
onOrderProcessing, | ||
onOrderCompleted, | ||
onOrderFailed, | ||
} = props; | ||
const { | ||
purchaseState: { | ||
signResponse, | ||
quote, | ||
}, | ||
} = useContext(PurchaseContext); | ||
|
||
const onFailedToLoad = () => { }; | ||
|
||
const { | ||
providersState: { | ||
toProviderInfo, | ||
toAddress, | ||
checkout, | ||
}, | ||
} = useProvidersContext(); | ||
|
||
const recipientEmail = ''; | ||
const recipientAddress = toAddress || ''; | ||
const isPassportWallet = toProviderInfo?.rdns === WalletProviderRdns.PASSPORT; | ||
const excludeFiatCurrencies = []; | ||
const { environment } = checkout.config; | ||
const executeTxn = signResponse?.transactions.find((txn) => txn.methodCall.startsWith('execute')); | ||
|
||
if (!signResponse || !executeTxn) { | ||
return null; | ||
} | ||
|
||
const nftData: TransakNFTData[] = useMemo( | ||
() => signResponse.order.products.map((product) => ({ | ||
collectionAddress: product.collectionAddress, | ||
imageURL: product.image, | ||
nftName: product.name, | ||
price: product.amount, | ||
quantity: product.qty, | ||
tokenID: product.tokenId, | ||
nftType: product.contractType || 'ERC721', | ||
})), | ||
[signResponse], | ||
); | ||
|
||
return ( | ||
<TransakIframe | ||
id="transak-iframe" | ||
type="nft-checkout" | ||
email={recipientEmail} | ||
walletAddress={recipientAddress} | ||
isPassportWallet={isPassportWallet} | ||
exchangeScreenTitle={t('views.PAY_WITH_CARD.screenTitle')} | ||
nftData={nftData} | ||
calldata={executeTxn.rawData} | ||
cryptoCurrencyCode={signResponse.order.currency.name} | ||
estimatedGasLimit={executeTxn.gasEstimate} | ||
partnerOrderId={executeTxn.params.reference} | ||
excludeFiatCurrencies={excludeFiatCurrencies} | ||
onInit={onInit} | ||
onOpen={onOpen} | ||
onOrderCreated={onOrderCreated} | ||
onOrderProcessing={onOrderProcessing} | ||
onOrderCompleted={onOrderCompleted} | ||
onOrderFailed={onOrderFailed} | ||
onFailedToLoad={onFailedToLoad} | ||
environment={environment} | ||
contractId={quote?.quote.config.contractId || ''} | ||
/> | ||
); | ||
} |
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
65 changes: 65 additions & 0 deletions
65
packages/checkout/widgets-lib/src/widgets/purchase/views/PayWithCard.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,65 @@ | ||
import { useState } from 'react'; | ||
import { Box, LoadingOverlay } from '@biom3/react'; | ||
|
||
import { useTranslation } from 'react-i18next'; | ||
import { HeaderNavigation } from '../../../components/Header/HeaderNavigation'; | ||
import { SimpleLayout } from '../../../components/SimpleLayout/SimpleLayout'; | ||
import { WithCard } from '../components/WithCard'; | ||
|
||
interface PayWithCardProps { | ||
onCloseButtonClick?: () => void; | ||
onError?: () => void; | ||
} | ||
|
||
export function PayWithCard({ | ||
onCloseButtonClick, | ||
onError, | ||
}: PayWithCardProps) { | ||
const [initialised, setInitialised] = useState(false); | ||
const { t } = useTranslation(); | ||
|
||
const onInit = () => setInitialised(true); | ||
|
||
const onOrderFailed = () => { | ||
onError?.(); | ||
}; | ||
|
||
return ( | ||
<SimpleLayout | ||
header={ | ||
initialised && ( | ||
<HeaderNavigation | ||
onCloseButtonClick={() => onCloseButtonClick?.()} | ||
/> | ||
) | ||
} | ||
> | ||
<> | ||
<LoadingOverlay visible={!initialised}> | ||
<LoadingOverlay.Content> | ||
<LoadingOverlay.Content.LoopingText | ||
text={[t('views.PAY_WITH_CARD.loading')]} | ||
/> | ||
</LoadingOverlay.Content> | ||
</LoadingOverlay> | ||
<Box | ||
style={{ | ||
display: 'block', | ||
position: 'relative', | ||
maxWidth: '420px', | ||
height: '565px', | ||
borderRadius: '1%', | ||
overflow: 'hidden', | ||
margin: '0 auto', | ||
width: '100%', | ||
}} | ||
> | ||
<WithCard | ||
onInit={onInit} | ||
onOrderFailed={onOrderFailed} | ||
/> | ||
</Box> | ||
</> | ||
</SimpleLayout> | ||
); | ||
} |
Oops, something went wrong.