Skip to content

Commit d24506e

Browse files
authored
Chore/banner swap update (#2557)
1 parent 3c11748 commit d24506e

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { Trans } from '@lingui/macro';
2+
import { Box, Typography } from '@mui/material';
23
import React from 'react';
34
import { BasicModal } from 'src/components/primitives/BasicModal';
45
import { UserAuthenticated } from 'src/components/UserAuthenticated';
6+
import { ConnectWalletButton } from 'src/components/WalletConnection/ConnectWalletButton';
57
import { ModalContextType, ModalType, useModalContext } from 'src/hooks/useModal';
8+
import { useRootStore } from 'src/store/root';
69

710
import { ModalWrapper } from '../FlowCommons/ModalWrapper';
811
import { SwapModalContent } from './SwapModalContent';
@@ -11,15 +14,26 @@ export const SwapModal = () => {
1114
const { type, close, args } = useModalContext() as ModalContextType<{
1215
underlyingAsset: string;
1316
}>;
17+
const account = useRootStore((store) => store.account);
18+
1419
return (
1520
<BasicModal open={type === ModalType.Swap} setOpen={close}>
16-
<ModalWrapper title={<Trans>Swap</Trans>} underlyingAsset={args.underlyingAsset}>
17-
{(params) => (
18-
<UserAuthenticated>
19-
{(user) => <SwapModalContent {...params} user={user} />}
20-
</UserAuthenticated>
21-
)}
22-
</ModalWrapper>
21+
{!account ? (
22+
<Box sx={{ display: 'flex', flexDirection: 'column', mt: 4, alignItems: 'center' }}>
23+
<Typography sx={{ mb: 6, textAlign: 'center' }} color="text.secondary">
24+
<Trans>Please connect your wallet to swap tokens.</Trans>
25+
</Typography>
26+
<ConnectWalletButton onClick={() => close()} />
27+
</Box>
28+
) : (
29+
<ModalWrapper title={<Trans>Swap</Trans>} underlyingAsset={args.underlyingAsset}>
30+
{(params) => (
31+
<UserAuthenticated>
32+
{(user) => <SwapModalContent {...params} user={user} />}
33+
</UserAuthenticated>
34+
)}
35+
</ModalWrapper>
36+
)}
2337
</BasicModal>
2438
);
2539
};

src/layouts/MainLayout.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import AnalyticsConsent from 'src/components/Analytics/AnalyticsConsent';
66
import { useModalContext } from 'src/hooks/useModal';
77
import { FeedbackModal } from 'src/layouts/FeedbackDialog';
88
// import { useRootStore } from 'src/store/root';
9-
import { CustomMarket } from 'src/ui-config/marketsConfig';
9+
// import { CustomMarket } from 'src/ui-config/marketsConfig';
1010
import { FORK_ENABLED } from 'src/utils/marketsAndNetworksConfig';
1111

1212
// import { useShallow } from 'zustand/shallow';
@@ -15,7 +15,8 @@ import { AppHeader } from './AppHeader';
1515
import TopBarNotify from './TopBarNotify';
1616

1717
const getCampaignConfigs = (
18-
openSwitch: (token?: string, chainId?: number) => void
18+
// openSwitch: (token?: string, chainId?: number) => void,
19+
openSwap: (underlyingAsset: string) => void
1920
// openMarket: (market: CustomMarket) => void
2021
) => ({
2122
[ChainId.base]: {
@@ -46,7 +47,7 @@ const getCampaignConfigs = (
4647
buttonText: 'Get Started',
4748
buttonAction: {
4849
type: 'function' as const,
49-
value: () => openSwitch(CustomMarket.proto_mainnet_v3),
50+
value: () => openSwap('0x3b3fb9c57858ef816833dc91565efcd85d96f634'),
5051
},
5152
bannerVersion: 'ethereum-swap-v1',
5253
// icon: '/icons/networks/ethereum.svg',
@@ -120,7 +121,7 @@ const getCampaignConfigs = (
120121
});
121122

122123
export function MainLayout({ children }: { children: ReactNode }) {
123-
const { openSwitch } = useModalContext();
124+
const { openSwap } = useModalContext();
124125
// const router = useRouter();
125126
// const setCurrentMarket = useRootStore(useShallow((store) => store.setCurrentMarket));
126127

@@ -129,7 +130,7 @@ export function MainLayout({ children }: { children: ReactNode }) {
129130
// router.push(`/markets/?marketName=${market}`);
130131
// };
131132

132-
const campaignConfigs = getCampaignConfigs(openSwitch);
133+
const campaignConfigs = getCampaignConfigs(openSwap);
133134

134135
return (
135136
<>

src/locales/en/messages.po

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ msgstr "Reload"
10641064
msgid "sGHO"
10651065
msgstr "sGHO"
10661066

1067+
#: src/components/transactions/Swap/SwapModal.tsx
10671068
#: src/components/transactions/Switch/BaseSwitchModal.tsx
10681069
#: src/components/transactions/Switch/BaseSwitchModalContent.tsx
10691070
msgid "Please connect your wallet to swap tokens."

0 commit comments

Comments
 (0)