From 45a464a7c9a1e6e0d4e32fa0540c16d6a05c67ce Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Mon, 6 Nov 2023 21:34:49 +0100 Subject: [PATCH] use NotificationsList for waku state --- packages/DApp/src/assets/images/refresh.svg | 6 ++++ packages/DApp/src/components/Modal.tsx | 11 +++++++ .../DApp/src/components/NotificationItem.tsx | 33 +++++++++++++++++-- .../DApp/src/components/NotificationsList.tsx | 9 ++++- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 packages/DApp/src/assets/images/refresh.svg diff --git a/packages/DApp/src/assets/images/refresh.svg b/packages/DApp/src/assets/images/refresh.svg new file mode 100644 index 0000000..60ec3da --- /dev/null +++ b/packages/DApp/src/assets/images/refresh.svg @@ -0,0 +1,6 @@ + + + diff --git a/packages/DApp/src/components/Modal.tsx b/packages/DApp/src/components/Modal.tsx index c3b7145..192950f 100644 --- a/packages/DApp/src/components/Modal.tsx +++ b/packages/DApp/src/components/Modal.tsx @@ -2,6 +2,7 @@ import React, { ReactNode, useEffect } from 'react' import styled from 'styled-components' import { Colors } from '../constants/styles' import closeIcon from '../assets/images/close.svg' +import refreshIcon from '../assets/images/refresh.svg' type ModalProps = { heading?: string @@ -92,3 +93,13 @@ export const CloseButton = styled.button` height: 24px; background-image: url(${closeIcon}); ` + +export const RetryButton = styled.button` + position: absolute; + content: ''; + top: 0; + right: 0; + width: 24px; + height: 24px; + background-image: url(${refreshIcon}); +` diff --git a/packages/DApp/src/components/NotificationItem.tsx b/packages/DApp/src/components/NotificationItem.tsx index e8118c2..0d12e8d 100644 --- a/packages/DApp/src/components/NotificationItem.tsx +++ b/packages/DApp/src/components/NotificationItem.tsx @@ -5,7 +5,7 @@ import styled from 'styled-components' import { Colors } from '../constants/styles' import { useCommunities } from '../hooks/useCommunities' import { LinkExternal } from './Link' -import { CloseButton } from './Modal' +import { CloseButton, RetryButton } from './Modal' import { getExplorerTransactionLink } from '@usedapp/core' interface NotificationItemProps { @@ -33,6 +33,7 @@ export function NotificationItem({ publicKey, text, transaction }: NotificationI View on Etherscan + setShow(false)} /> ) @@ -40,6 +41,28 @@ export function NotificationItem({ publicKey, text, transaction }: NotificationI return null } +export function NotificationInfoItem({ text }: { text: string }) { + return ( + + + {text} + + + ) +} + +export function NotificationErrorItem({ text, action }: { text: string; action: () => void }) { + return ( + + + {text} + + + action()} /> + + ) +} + const NotificationBlock = styled.div` display: flex; background: ${Colors.VioletSecondaryLight}; @@ -47,7 +70,6 @@ const NotificationBlock = styled.div` width: 345px; border-radius: 16px; filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.15)); - z-index: 9999; ` const NotificationLogoWrap = styled.div` @@ -90,3 +112,10 @@ const NotificationCloseButton = styled(CloseButton)` bottom: 50%; transform: translateY(50%); ` + +const NotificationRetryButton = styled(RetryButton)` + top: unset; + right: 13px; + bottom: 50%; + transform: translateY(50%); +` diff --git a/packages/DApp/src/components/NotificationsList.tsx b/packages/DApp/src/components/NotificationsList.tsx index 1b8e8db..40404c6 100644 --- a/packages/DApp/src/components/NotificationsList.tsx +++ b/packages/DApp/src/components/NotificationsList.tsx @@ -3,14 +3,20 @@ import React from 'react' import styled from 'styled-components' import { AnimationNotification, AnimationNotificationMobile } from '../constants/animation' import { useContracts } from '../hooks/useContracts' -import { NotificationItem } from './NotificationItem' +import { NotificationItem, NotificationInfoItem, NotificationErrorItem } from './NotificationItem' +import { useWaku } from '../providers/waku/provider' export function NotificationsList() { const { notifications } = useNotifications() const { votingContract } = useContracts() + const { isLoading, isError, restart } = useWaku() return ( + {isLoading && } + + {!isLoading && isError && } + {notifications.map((notification) => { if ('receipt' in notification) { return notification.receipt.logs.map((log) => { @@ -62,6 +68,7 @@ const NotificationsWrapper = styled.div` flex-direction: column; transition: all 0.3s; animation: ${AnimationNotification} 2s ease; + z-index: 100; @media (max-width: 600px) { top: unset;