Skip to content

Commit

Permalink
Add notify (#967)
Browse files Browse the repository at this point in the history
* add Notifi

* remove discord & change cratio save button

* ui fixes

* Deps

* Dont rely on connector

* Hide notification icon when in delegate mode

* Prettier

* Lazy load notificard

* update version, split chains (#973)

* update version, split chains

* add unread counter

* fix history icon alignment (#985)

* update version, split chains

* add unread counter

* align history icons

* Update notifi.css

* update npm package

* Fix deps

* Node v16 is deprecated

* yarn pretty:fix

* Lint issues

* add discord support (#987)

* upgrade sdk (#991)

* deps

---------

Co-authored-by: Haoqian-Zheng <[email protected]>
  • Loading branch information
0xjocke and Haoqian-Zheng authored Oct 24, 2023
1 parent 28c0c40 commit a2d7221
Show file tree
Hide file tree
Showing 27 changed files with 2,147 additions and 7 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 10 additions & 1 deletion v2/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
GuideIcon,
NineDots,
LoansIcon,
// NotificationsIcon,
OptimismIcon,
// SettingsIcon,
StakingIcon,
Expand All @@ -45,6 +44,7 @@ import { WalletModal } from '@snx-v2/WalletModal';
import { ContractContext } from '@snx-v2/ContractContext';
import { useDelegateWallet } from '@snx-v2/useDelegateWallet';
import { EXTERNAL_LINKS } from '@snx-v2/Constants';
import { NotifiButton, NotifiContextWrapper } from '@snx-v2/NotifiButton';

interface NavigationProps {
currentNetwork: NetworkId;
Expand Down Expand Up @@ -112,6 +112,15 @@ export const NavigationUI = ({
>
<Link to="/">{size === 'desktop' ? <StakingLogo /> : <StakingIcon />}</Link>
<Flex alignItems="center">
{isWalletConnected && walletAddress && !delegateWallet && (
<>
{size === 'desktop' && (
<NotifiContextWrapper>
<NotifiButton />
</NotifiContextWrapper>
)}
</>
)}
{isWalletConnected && walletAddress && (
<>
{size === 'desktop' && (
Expand Down
1 change: 1 addition & 0 deletions v2/components/Navigation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@snx-v2/Constants": "workspace:*",
"@snx-v2/ContractContext": "workspace:*",
"@snx-v2/EpochPrice": "workspace:^",
"@snx-v2/NotifiButton": "workspace:*",
"@snx-v2/UserBalances": "workspace:*",
"@snx-v2/WalletModal": "workspace:*",
"@snx-v2/formatters": "workspace:*",
Expand Down
70 changes: 70 additions & 0 deletions v2/components/Notifi/NotifiCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
NotifiInputFieldsText,
NotifiInputSeparators,
NotifiSubscriptionCard,
} from '@notifi-network/notifi-react-card';
import './notifi.css';
import React, { useContext } from 'react';
import { ContractContext } from '@snx-v2/ContractContext';
import { NetworkIdByName } from '@snx-v2/useSynthetixContracts';

const isTestnet = (networkId: null | number) => {
if (networkId === NetworkIdByName['mainnet-ovm'] || networkId === NetworkIdByName['mainnet']) {
return false;
}
return true;
};
export const NotifiCard: React.FC<{ onClose: () => void }> = ({ onClose }) => {
const { networkId, walletAddress } = useContext(ContractContext);
if (walletAddress === null || networkId === null) {
// account is required
return null;
}
const isL2 = networkId === NetworkIdByName['mainnet-ovm'];
const isMainnet = !isTestnet(networkId);

const cardId = isMainnet
? isL2
? '283fa53b4b8e4ed1a2234615bf01d240'
: '5ece3cd3ec504576b10ab396d619dc9b'
: '8a569abd38974f76837960bd9bf36049';

const inputLabels: NotifiInputFieldsText = {
label: {},
placeholderText: {
email: 'Email address',
telegram: 'Telegram ID',
},
};

const inputSeparators: NotifiInputSeparators = {
emailSeparator: {
content: 'OR',
},
telegramSeparator: {
content: 'OR',
},
};

return (
<NotifiSubscriptionCard
cardId={cardId}
inputLabels={inputLabels}
inputSeparators={inputSeparators}
inputs={{ userWallet: walletAddress }}
copy={{
FetchedStateCard: {
SubscriptionCardV1: {
EditCard: {
AlertListPreview: {
description: 'Get real-time alerts to the destinations of your choice',
},
},
},
},
}}
darkMode
onClose={onClose}
/>
);
};
3 changes: 3 additions & 0 deletions v2/components/Notifi/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { NotifiCard } from './NotifiCard';
export { NotifiCard } from './NotifiCard';
export default NotifiCard;
Loading

1 comment on commit a2d7221

@vercel
Copy link

@vercel vercel bot commented on a2d7221 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

v2-storybook – ./v2/ui

v2-storybook-git-master-synthetixio.vercel.app
staking-storybook.vercel.app
v2-storybook-synthetixio.vercel.app

Please sign in to comment.