From 236a4dc1457da7131eddfe8bc12eb9e91581c032 Mon Sep 17 00:00:00 2001 From: Jordan Frankfurt Date: Tue, 21 Mar 2023 18:07:57 -0400 Subject: [PATCH] feat: add tax service discount to help menu (#6211) --- src/components/NavBar/MenuDropdown.tsx | 11 ++++++++- .../TaxServiceModal/TaxServiceBanner.tsx | 24 +++++++++++-------- src/state/application/hooks.ts | 4 ++++ src/state/application/reducer.ts | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/components/NavBar/MenuDropdown.tsx b/src/components/NavBar/MenuDropdown.tsx index 0cb6156937..49ae8b1907 100644 --- a/src/components/NavBar/MenuDropdown.tsx +++ b/src/components/NavBar/MenuDropdown.tsx @@ -19,7 +19,7 @@ import { NavLink, NavLinkProps } from 'react-router-dom' import styled from 'styled-components/macro' import { isDevelopmentEnv, isStagingEnv } from 'utils/env' -import { useToggleModal } from '../../state/application/hooks' +import { useToggleModal, useToggleTaxServiceModal } from '../../state/application/hooks' import { ApplicationModal } from '../../state/application/reducer' import * as styles from './MenuDropdown.css' import { NavDropdown } from './NavDropdown' @@ -123,6 +123,7 @@ export const MenuDropdown = () => { const openFeatureFlagsModal = useToggleModal(ApplicationModal.FEATURE_FLAGS) const ref = useRef(null) useOnClickOutside(ref, isOpen ? toggleOpen : undefined) + const toggleTaxServiceModal = useToggleTaxServiceModal() return ( <> @@ -163,6 +164,14 @@ export const MenuDropdown = () => { Help center + { + toggleTaxServiceModal() + toggleOpen() + }} + > + Save on Tax Services ↗ + Documentation diff --git a/src/components/TaxServiceModal/TaxServiceBanner.tsx b/src/components/TaxServiceModal/TaxServiceBanner.tsx index 10c352c9ad..1ec81034db 100644 --- a/src/components/TaxServiceModal/TaxServiceBanner.tsx +++ b/src/components/TaxServiceModal/TaxServiceBanner.tsx @@ -5,6 +5,8 @@ import { ButtonEmphasis, ButtonSize, ThemeButton } from 'components/Button' import { bodySmall, subhead } from 'nft/css/common.css' import { useCallback, useState } from 'react' import { X } from 'react-feather' +import { useModalIsOpen, useToggleTaxServiceModal } from 'state/application/hooks' +import { ApplicationModal } from 'state/application/reducer' import { useTaxServiceDismissal } from 'state/user/hooks' import { useIsDarkMode } from 'state/user/hooks' import styled from 'styled-components/macro' @@ -117,7 +119,9 @@ const MAX_RENDER_COUNT = 1 export default function TaxServiceBanner() { const isDarkMode = useIsDarkMode() const [dismissals, addTaxServiceDismissal] = useTaxServiceDismissal() - const [modalOpen, setModalOpen] = useState(false) + const modalOpen = useModalIsOpen(ApplicationModal.TAX_SERVICE) + const toggleTaxServiceModal = useToggleTaxServiceModal() + const sessionStorageTaxServiceDismissed = sessionStorage.getItem(TAX_SERVICE_DISMISSED) if (!sessionStorageTaxServiceDismissed) { @@ -126,9 +130,6 @@ export default function TaxServiceBanner() { const [bannerOpen, setBannerOpen] = useState( sessionStorageTaxServiceDismissed !== 'true' && (dismissals === undefined || dismissals < MAX_RENDER_COUNT) ) - const onDismiss = useCallback(() => { - setModalOpen(false) - }, []) const handleClose = useCallback(() => { sessionStorage.setItem(TAX_SERVICE_DISMISSED, 'true') @@ -136,11 +137,14 @@ export default function TaxServiceBanner() { dismissals === undefined ? addTaxServiceDismissal(1) : addTaxServiceDismissal(dismissals + 1) }, [addTaxServiceDismissal, dismissals]) - const handleLearnMoreClick = useCallback((e: any) => { - e.preventDefault() - e.stopPropagation() - setModalOpen(true) - }, []) + const handleLearnMoreClick = useCallback( + (e: any) => { + e.preventDefault() + e.stopPropagation() + toggleTaxServiceModal() + }, + [toggleTaxServiceModal] + ) return ( @@ -175,7 +179,7 @@ export default function TaxServiceBanner() { - + ) } diff --git a/src/state/application/hooks.ts b/src/state/application/hooks.ts index 42af1ba38d..66f5a8e9ed 100644 --- a/src/state/application/hooks.ts +++ b/src/state/application/hooks.ts @@ -122,6 +122,10 @@ export function useToggleSelfClaimModal(): () => void { return useToggleModal(ApplicationModal.SELF_CLAIM) } +export function useToggleTaxServiceModal(): () => void { + return useToggleModal(ApplicationModal.TAX_SERVICE) +} + export function useToggleDelegateModal(): () => void { return useToggleModal(ApplicationModal.DELEGATE) } diff --git a/src/state/application/reducer.ts b/src/state/application/reducer.ts index ea4f7b570c..2ecfd08742 100644 --- a/src/state/application/reducer.ts +++ b/src/state/application/reducer.ts @@ -30,6 +30,7 @@ export enum ApplicationModal { SELF_CLAIM, SETTINGS, SHARE, + TAX_SERVICE, TIME_SELECTOR, VOTE, WALLET,