Skip to content

Commit dbb1908

Browse files
mimi-imtblluads
andauthored
feat: Add fiat & change wallet ability from the route drawer (#2518)
Co-authored-by: Luã de Souza <[email protected]>
1 parent cf8708c commit dbb1908

File tree

8 files changed

+35
-6
lines changed

8 files changed

+35
-6
lines changed

packages/checkout/widgets-lib/src/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@
909909
"drawer": {
910910
"options": {
911911
"heading": "Pay from",
912-
"moreOptionsDividerText": "More ways to Pay",
912+
"moreOptionsDividerText": "Other ways to Pay",
913913
"loadingText1": "Finding the best value",
914914
"loadingText2": "across all chains",
915915
"noRoutes": {
@@ -921,6 +921,7 @@
921921
"caption": "Swap tokens on this network.",
922922
"disabledCaption": "Currently not available."
923923
},
924+
"changeWallet": "Choose another wallet",
924925
"debit": {
925926
"heading": "Debit Card",
926927
"caption": "",

packages/checkout/widgets-lib/src/locales/ja.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@
892892
"drawer": {
893893
"options": {
894894
"heading": "支払い元",
895-
"moreOptionsDividerText": "支払い方法の追加",
895+
"moreOptionsDividerText": "その他の支払い方法",
896896
"loadingText1": "最適な価値を検索中",
897897
"loadingText2": "すべてのチェーンを横断",
898898
"noRoutes": {
@@ -904,6 +904,7 @@
904904
"caption": "このネットワークでトークンを交換します。",
905905
"disabledCaption": "現在利用できません。"
906906
},
907+
"changeWallet": "別のウォレットを選択",
907908
"debit": {
908909
"heading": "デビットカード",
909910
"caption": "",

packages/checkout/widgets-lib/src/locales/ko.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@
901901
"caption": "이 네트워크에서 토큰을 교환합니다.",
902902
"disabledCaption": "현재 이용할 수 없습니다."
903903
},
904+
"changeWallet": "다른 지갑 선택",
904905
"debit": {
905906
"heading": "직불 카드",
906907
"caption": "",

packages/checkout/widgets-lib/src/locales/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@
889889
"drawer": {
890890
"options": {
891891
"heading": "支付来源",
892-
"moreOptionsDividerText": "更多支付方式",
892+
"moreOptionsDividerText": "其他支付方式",
893893
"loadingText1": "寻找最佳价值",
894894
"loadingText2": "跨所有链",
895895
"noRoutes": {
@@ -901,6 +901,7 @@
901901
"caption": "在此网络上交换代币。",
902902
"disabledCaption": "当前不可用。"
903903
},
904+
"changeWallet": "选择另一个钱包",
904905
"debit": {
905906
"heading": "借记卡",
906907
"caption": "",

packages/checkout/widgets-lib/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/FiatOption.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export function FiatOption<RC extends ReactElement | undefined = undefined>({
5656
}`,
5757
)}
5858
</MenuItem.Caption>
59-
{!disabled && <MenuItem.IntentIcon />}
6059
</MenuItem>
6160
);
6261
}

packages/checkout/widgets-lib/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptions.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface OptionsProps {
2525
onCardClick: (type: FiatOptionType) => void;
2626
onRouteClick: (route: RouteData, index: number) => void;
2727
onDirectCryptoPayClick: (route: DirectCryptoPayData, index: number) => void;
28+
onChangeWalletClick: () => void;
2829
routes?: RouteData[];
2930
size?: MenuItemSize;
3031
showOnrampOption?: boolean;
@@ -42,6 +43,7 @@ export function RouteOptions({
4243
onCardClick,
4344
onRouteClick,
4445
onDirectCryptoPayClick,
46+
onChangeWalletClick,
4547
size,
4648
showOnrampOption,
4749
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -137,11 +139,26 @@ export function RouteOptions({
137139

138140
{!routes?.length && !insufficientBalance && renderLoading()}
139141

140-
{showOnrampOption && (
142+
{showOnrampOption && (routes?.length || insufficientBalance) && (
141143
<>
142144
<Divider size="xSmall" sx={{ my: 'base.spacing.x2' }}>
143145
{t('views.PURCHASE.drawer.options.moreOptionsDividerText')}
144146
</Divider>
147+
<MenuItem
148+
emphasized
149+
onClick={onChangeWalletClick}
150+
size="small"
151+
>
152+
<MenuItem.FramedIcon
153+
icon="Wallet"
154+
variant="bold"
155+
emphasized={false}
156+
/>
157+
<MenuItem.Label>
158+
{t('views.PURCHASE.drawer.options.changeWallet')}
159+
</MenuItem.Label>
160+
</MenuItem>
161+
145162
{defaultFiatOptions.map((type, idx) => (
146163
<FiatOption
147164
key={`fiat-option-${type}`}

packages/checkout/widgets-lib/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptionsDrawer.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type OptionsDrawerProps = {
2525
onRouteClick: (route: RouteData) => void;
2626
onCardClick: (type: FiatOptionType) => void;
2727
onDirectCryptoPayClick: (route: DirectCryptoPayData) => void;
28+
onChangeWalletClick: () => void;
2829
showOnrampOption?: boolean;
2930
showDirectCryptoPayOption?: boolean;
3031
showSwapOption?: boolean;
@@ -42,6 +43,7 @@ export function RouteOptionsDrawer({
4243
onRouteClick,
4344
onCardClick,
4445
onDirectCryptoPayClick,
46+
onChangeWalletClick,
4547
showOnrampOption,
4648
showDirectCryptoPayOption,
4749
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -77,6 +79,11 @@ export function RouteOptionsDrawer({
7779
onDirectCryptoPayClick(route);
7880
};
7981

82+
const handleOnChangeWalletClick = () => {
83+
onClose();
84+
onChangeWalletClick();
85+
};
86+
8087
useEffect(() => {
8188
if (!visible) {
8289
return;
@@ -132,7 +139,6 @@ export function RouteOptionsDrawer({
132139
sx={{ c: 'inherit', fontSize: 'inherit' }}
133140
/>
134141
</MenuItem.Caption>
135-
136142
<MenuItem.StatefulButtCon icon="ChevronExpand" onClick={onClose} />
137143
</MenuItem>
138144
<RouteOptions
@@ -143,6 +149,7 @@ export function RouteOptionsDrawer({
143149
onCardClick={onCardClick}
144150
onRouteClick={handleOnRouteClick}
145151
onDirectCryptoPayClick={handleOnDirectCryptoPayClick}
152+
onChangeWalletClick={handleOnChangeWalletClick}
146153
showOnrampOption={showOnrampOption}
147154
showDirectCryptoPayOption={showDirectCryptoPayOption}
148155
insufficientBalance={insufficientBalance}

packages/checkout/widgets-lib/src/widgets/purchase/views/Purchase.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,12 +693,14 @@ export function Purchase({
693693
chains={chains}
694694
showSwapOption={showSwapOption}
695695
showBridgeOption={showBridgeOption}
696+
showOnrampOption={shouldShowOnRampOption}
696697
showDirectCryptoPayOption
697698
visible={showOptionsDrawer}
698699
onClose={() => setShowOptionsDrawer(false)}
699700
onCardClick={handlePayWithCardClick}
700701
onRouteClick={handleRouteClick}
701702
onDirectCryptoPayClick={handleDirectCryptoPayClick}
703+
onChangeWalletClick={() => setShowPayWithWalletDrawer(true)}
702704
insufficientBalance={insufficientBalance}
703705
directCryptoPayRoutes={directCryptoPayRoutes}
704706
/>

0 commit comments

Comments
 (0)