Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { useState } from 'react';
import { useHistory } from 'react-router';
import { Dropdown } from 'antd';

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

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

export const NotificationsBellContainer = ({ popupView }: NotificationsCenterContainerProps): React.ReactElement => {
const posthog = usePostHogClientContext();

const history = useHistory();
const [isOpen, setIsOpen] = useState(false);

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

const handleViewAll = () => {
setIsOpen(false);
history.push(walletRoutePaths.notifications);
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import '../../../../../packages/core/src/ui/styles/theme.scss';
@import '../../../../../packages/common/src/ui/styles/theme.scss';

.markAllAsRead {
Copy link
Contributor

Choose a reason for hiding this comment

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

kindly rename to be something more generic, eg: button, otherwise, if copy of this component changes, you'll need to rename class as well*

max-width: size_unit(25);
}

.sectionTitle {
margin-bottom: size_unit(5.5);
Copy link
Contributor

Choose a reason for hiding this comment

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

there is margin specific properties available on Flex component
mb={$44}


.title {
margin-bottom: 0px !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Box, Flex } from '@input-output-hk/lace-ui-toolkit';

import { Button, NavigationButton } from '@lace/common';
import { SectionTitle } from '@components/Layout/SectionTitle';

import styles from './NotificationsCenter.module.scss';

export interface NotificationsCenterProps {
onBack: () => void;
onMarkAllAsRead: () => void;
popupView?: boolean;
}

export const NotificationsCenter = ({
onBack,
onMarkAllAsRead,
popupView
}: NotificationsCenterProps): React.ReactElement => {
const { t } = useTranslation();

return (
<Box p="$24">
<Flex className={styles.sectionTitle} justifyContent="space-between">
<SectionTitle
classname={styles.title}
sideText={`(${1})`}
title={
<Flex alignItems="center" gap="$8">
<NavigationButton icon="arrow" onClick={onBack} />
{t('notificationsCenter.title')}
</Flex>
}
/>
{!popupView && (
<Button
className={styles.markAllAsRead}
block
color="gradient"
data-testid="notifications-bell"
onClick={onMarkAllAsRead}
>
{t('notificationsCenter.markAllAsRead')}
</Button>
)}
</Flex>
Notifications Center (Placeholder content)
</Box>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { useHistory } from 'react-router';

import { usePostHogClientContext } from '@providers/PostHogClientProvider';
import { ExperimentName } from '@lib/scripts/types/feature-flags';
import { walletRoutePaths } from '@routes';
import { useWalletStore } from '@stores';
import { APP_MODE_POPUP } from '@src/utils/constants';

import { NotificationsCenter } from './NotificationsCenter';

export const NotificationsCenterContainer = (): React.ReactElement => {
const posthog = usePostHogClientContext();
const history = useHistory();
const { walletUI } = useWalletStore();

if (!posthog?.isFeatureFlagEnabled(ExperimentName.NOTIFICATIONS_CENTER)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you could render this route conditionally in apps/browser-extension-wallet/src/routes/ExtensionRoutes.tsx

history.push(walletRoutePaths.assets);

// eslint-disable-next-line unicorn/no-null
return null;
}

return (
<NotificationsCenter
onBack={() => history.goBack()}
onMarkAllAsRead={() => {
// TODO connect with notifications center
// eslint-disable-next-line no-console
console.log('onMarkAllAsRead');
}}
popupView={walletUI.appMode === APP_MODE_POPUP}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';

import { Layout, SectionLayout } from '@src/views/browser-view/components/Layout';
import { EducationalList } from '@src/views/browser-view/components';
import { useTranslation } from 'react-i18next';
import { getEducationalList } from '@src/views/browser-view/features/assets/components/AssetEducationalList/AssetEducationalList';

import { NotificationsCenterContainer } from './NotificationsCenterContainer';

export const NotificationsCenterLayout = (): React.ReactElement => {
const { t } = useTranslation();

const educationalItems = getEducationalList(t);

return (
<>
<Layout>
<SectionLayout
sidePanelContent={
<EducationalList items={educationalItems} title={t('browserView.sidePanel.aboutYourWallet')} />
}
>
<NotificationsCenterContainer />
</SectionLayout>
</Layout>
</>
);
};
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './NotificationsBellContainer';
export * from './NotificationsCenterContainer';
export * from './NotificationsCenterLayout';
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { NftDetail, Nfts } from '@src/features/nfts';
import { useWalletStore } from '@stores';
import { config } from '@src/config';
import { Voting } from '@src/features/voting-beta/components';
import { NotificationsCenterContainer } from '@src/components/NotificationsCenter';

const { GOV_TOOLS_URLS } = config();

Expand All @@ -30,6 +31,7 @@ export const ExtensionRoutes = (): React.ReactElement => {
<Route exact path={walletRoutePaths.activity} component={Activity} />
<Route exact path={walletRoutePaths.send} component={Send} />
<Route exact path={walletRoutePaths.nftDetail} component={NftDetail} />
<Route exact path={walletRoutePaths.notifications} component={NotificationsCenterContainer} />
{!isSharedWallet && <Route exact path={walletRoutePaths.earn} component={DelegationContainer} />}
<Route exact path={walletRoutePaths.addressBook} component={AddressBook} />
<Route exact path={walletRoutePaths.settings} component={Settings} />
Expand Down
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/src/routes/wallet-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const walletRoutePaths = {
confirmDelegation: '/delegate/confirm',
delegate: '/delegate',
earn: '/earn',
notifications: '/notifications',
nftDetail: '/nft/:id',
nfts: '/nfts',
assets: '/assets',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { catchAndBrandExtensionApiError } from '@utils/catch-and-brand-extension
import { removePreloaderIfExists } from '@utils/remove-reloader-if-exists';
import { ENHANCED_ANALYTICS_OPT_IN_STATUS_LS_KEY } from '@providers/AnalyticsProvider/config';
import { EnhancedAnalyticsOptInStatus } from '@providers/AnalyticsProvider/analyticsTracker';
import { NotificationsCenterLayout } from '@components/NotificationsCenter';

export const defaultRoutes: RouteMap = [
{
Expand Down Expand Up @@ -84,6 +85,10 @@ export const defaultRoutes: RouteMap = [
{
path: routes.nfts,
component: NftsLayout
},
{
path: routes.notifications,
component: NotificationsCenterLayout
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@
"notificationsCenter.allClear.description": "You don't have any notifications currently",
"notificationsCenter.manageSubscriptions": "Manage subscriptions",
"notificationsCenter.markAllAsRead": "Mark all as read",
"notificationsCenter.title": "Notifications",
"notificationsCenter.viewAll": "View all",
"poolDetails.delegate": "Delegate to this pool",
"poolDetails.sectionTitle": "Pool detail",
Expand Down
Loading