Skip to content

Commit bf82d17

Browse files
committed
feat: add the notifications center
1 parent 17bc875 commit bf82d17

File tree

10 files changed

+143
-1
lines changed

10 files changed

+143
-1
lines changed

apps/browser-extension-wallet/src/components/NotificationsCenter/NotificationsBellContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React, { useState } from 'react';
2+
import { useHistory } from 'react-router';
23
import { Dropdown } from 'antd';
34

45
import { usePostHogClientContext } from '@providers/PostHogClientProvider';
56
import { ExperimentName } from '@lib/scripts/types/feature-flags';
7+
import { walletRoutePaths } from '@routes';
68

79
import { NotificationsBell } from './NotificationsBell';
810
import { NotificationsDropDown } from './NotificationsDropDown';
@@ -13,7 +15,7 @@ export interface NotificationsCenterContainerProps {
1315

1416
export const NotificationsBellContainer = ({ popupView }: NotificationsCenterContainerProps): React.ReactElement => {
1517
const posthog = usePostHogClientContext();
16-
18+
const history = useHistory();
1719
const [isOpen, setIsOpen] = useState(false);
1820

1921
// TODO Connect with notifications center
@@ -38,6 +40,7 @@ export const NotificationsBellContainer = ({ popupView }: NotificationsCenterCon
3840

3941
const handleViewAll = () => {
4042
setIsOpen(false);
43+
history.push(walletRoutePaths.notifications);
4144
};
4245

4346
return (
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@import '../../../../../packages/core/src/ui/styles/theme.scss';
2+
@import '../../../../../packages/common/src/ui/styles/theme.scss';
3+
4+
.markAllAsRead {
5+
max-width: size_unit(25);
6+
}
7+
8+
.sectionTitle {
9+
margin-bottom: size_unit(5.5);
10+
11+
.title {
12+
margin-bottom: 0px !important;
13+
}
14+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { Box, Flex } from '@input-output-hk/lace-ui-toolkit';
4+
5+
import { Button, NavigationButton } from '@lace/common';
6+
import { SectionTitle } from '@components/Layout/SectionTitle';
7+
8+
import styles from './NotificationsCenter.module.scss';
9+
10+
export interface NotificationsCenterProps {
11+
onBack: () => void;
12+
onMarkAllAsRead: () => void;
13+
popupView?: boolean;
14+
}
15+
16+
export const NotificationsCenter = ({
17+
onBack,
18+
onMarkAllAsRead,
19+
popupView
20+
}: NotificationsCenterProps): React.ReactElement => {
21+
const { t } = useTranslation();
22+
23+
return (
24+
<Box p="$24">
25+
<Flex className={styles.sectionTitle} justifyContent="space-between">
26+
<SectionTitle
27+
classname={styles.title}
28+
sideText={`(${1})`}
29+
title={
30+
<Flex alignItems="center" gap="$8">
31+
<NavigationButton icon="arrow" onClick={onBack} />
32+
{t('notificationsCenter.title')}
33+
</Flex>
34+
}
35+
/>
36+
{!popupView && (
37+
<Button
38+
className={styles.markAllAsRead}
39+
block
40+
color="gradient"
41+
data-testid="notifications-bell"
42+
onClick={onMarkAllAsRead}
43+
>
44+
{t('notificationsCenter.markAllAsRead')}
45+
</Button>
46+
)}
47+
</Flex>
48+
Notifications Center (Placeholder content)
49+
</Box>
50+
);
51+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import { useHistory } from 'react-router';
3+
4+
import { usePostHogClientContext } from '@providers/PostHogClientProvider';
5+
import { ExperimentName } from '@lib/scripts/types/feature-flags';
6+
import { walletRoutePaths } from '@routes';
7+
import { useWalletStore } from '@stores';
8+
import { APP_MODE_POPUP } from '@src/utils/constants';
9+
10+
import { NotificationsCenter } from './NotificationsCenter';
11+
12+
export const NotificationsCenterContainer = (): React.ReactElement => {
13+
const posthog = usePostHogClientContext();
14+
const history = useHistory();
15+
const { walletUI } = useWalletStore();
16+
17+
if (!posthog?.isFeatureFlagEnabled(ExperimentName.NOTIFICATIONS_CENTER)) {
18+
history.push(walletRoutePaths.assets);
19+
20+
// eslint-disable-next-line unicorn/no-null
21+
return null;
22+
}
23+
24+
return (
25+
<NotificationsCenter
26+
onBack={() => history.goBack()}
27+
onMarkAllAsRead={() => {
28+
// TODO connect with notifications center
29+
// eslint-disable-next-line no-console
30+
console.log('onMarkAllAsRead');
31+
}}
32+
popupView={walletUI.appMode === APP_MODE_POPUP}
33+
/>
34+
);
35+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
3+
import { Layout, SectionLayout } from '@src/views/browser-view/components/Layout';
4+
import { EducationalList } from '@src/views/browser-view/components';
5+
import { useTranslation } from 'react-i18next';
6+
import { getEducationalList } from '@src/views/browser-view/features/assets/components/AssetEducationalList/AssetEducationalList';
7+
8+
import { NotificationsCenterContainer } from './NotificationsCenterContainer';
9+
10+
export const NotificationsCenterLayout = (): React.ReactElement => {
11+
const { t } = useTranslation();
12+
13+
const educationalItems = getEducationalList(t);
14+
15+
return (
16+
<>
17+
<Layout>
18+
<SectionLayout
19+
sidePanelContent={
20+
<EducationalList items={educationalItems} title={t('browserView.sidePanel.aboutYourWallet')} />
21+
}
22+
>
23+
<NotificationsCenterContainer />
24+
</SectionLayout>
25+
</Layout>
26+
</>
27+
);
28+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export * from './NotificationsBellContainer';
2+
export * from './NotificationsCenterContainer';
3+
export * from './NotificationsCenterLayout';

apps/browser-extension-wallet/src/routes/ExtensionRoutes.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { NftDetail, Nfts } from '@src/features/nfts';
1515
import { useWalletStore } from '@stores';
1616
import { config } from '@src/config';
1717
import { Voting } from '@src/features/voting-beta/components';
18+
import { NotificationsCenterContainer } from '@src/components/NotificationsCenter';
1819

1920
const { GOV_TOOLS_URLS } = config();
2021

@@ -30,6 +31,7 @@ export const ExtensionRoutes = (): React.ReactElement => {
3031
<Route exact path={walletRoutePaths.activity} component={Activity} />
3132
<Route exact path={walletRoutePaths.send} component={Send} />
3233
<Route exact path={walletRoutePaths.nftDetail} component={NftDetail} />
34+
<Route exact path={walletRoutePaths.notifications} component={NotificationsCenterContainer} />
3335
{!isSharedWallet && <Route exact path={walletRoutePaths.earn} component={DelegationContainer} />}
3436
<Route exact path={walletRoutePaths.addressBook} component={AddressBook} />
3537
<Route exact path={walletRoutePaths.settings} component={Settings} />

apps/browser-extension-wallet/src/routes/wallet-paths.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const walletRoutePaths = {
55
confirmDelegation: '/delegate/confirm',
66
delegate: '/delegate',
77
earn: '/earn',
8+
notifications: '/notifications',
89
nftDetail: '/nft/:id',
910
nfts: '/nfts',
1011
assets: '/assets',

apps/browser-extension-wallet/src/views/browser-view/routes/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { catchAndBrandExtensionApiError } from '@utils/catch-and-brand-extension
4747
import { removePreloaderIfExists } from '@utils/remove-reloader-if-exists';
4848
import { ENHANCED_ANALYTICS_OPT_IN_STATUS_LS_KEY } from '@providers/AnalyticsProvider/config';
4949
import { EnhancedAnalyticsOptInStatus } from '@providers/AnalyticsProvider/analyticsTracker';
50+
import { NotificationsCenterLayout } from '@components/NotificationsCenter';
5051

5152
export const defaultRoutes: RouteMap = [
5253
{
@@ -84,6 +85,10 @@ export const defaultRoutes: RouteMap = [
8485
{
8586
path: routes.nfts,
8687
component: NftsLayout
88+
},
89+
{
90+
path: routes.notifications,
91+
component: NotificationsCenterLayout
8792
}
8893
];
8994

packages/translation/src/lib/translations/browser-extension-wallet/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@
786786
"notificationsCenter.allClear.description": "You don't have any notifications currently",
787787
"notificationsCenter.manageSubscriptions": "Manage subscriptions",
788788
"notificationsCenter.markAllAsRead": "Mark all as read",
789+
"notificationsCenter.title": "Notifications",
789790
"notificationsCenter.viewAll": "View all",
790791
"poolDetails.delegate": "Delegate to this pool",
791792
"poolDetails.sectionTitle": "Pool detail",

0 commit comments

Comments
 (0)