From 08591fcd8693254ba85fe9eaab301337bbd36583 Mon Sep 17 00:00:00 2001 From: Roy Johnson Date: Thu, 5 Oct 2023 17:12:15 -0500 Subject: [PATCH] Show give dialog when downloading PDF from new Subjects For: https://github.com/openstax/openstax.org/issues/2352 --- src/app/components/book-tile/book-tile.js | 36 ++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/app/components/book-tile/book-tile.js b/src/app/components/book-tile/book-tile.js index 8b7f09fd2..531401416 100644 --- a/src/app/components/book-tile/book-tile.js +++ b/src/app/components/book-tile/book-tile.js @@ -8,6 +8,8 @@ import { FormattedMessage, useIntl } from 'react-intl'; import useAmazonAssociatesLink from '~/pages/details/common/get-this-title-files//amazon-associates-link'; import { usePrintCopyDialog, isRealPrintLink } from '~/pages/details/common/get-this-title-files/options'; import bookPromise from '~/models/book-titles'; +import useGiveDialog from '~/pages/details/common/get-this-title-files/give-before-pdf/give-before-pdf'; +import {isMobileDisplay} from '~/helpers/device'; import cn from 'classnames'; import './book-tile.scss'; @@ -85,13 +87,7 @@ function GetTheBookDropdown({ bookInfo }) { /> { - pdfLink && - - - + pdfLink && }
@@ -115,6 +111,32 @@ function GetTheBookDropdown({ bookInfo }) { ); } +function PDFLinkWithGiveDialog({pdfLink}) { + const {GiveDialog, open, enabled} = useGiveDialog(); + + const openGiveDialog = React.useCallback( + (event) => { + if (enabled && !isMobileDisplay()) { + event.preventDefault(); + open(); + } + }, + [enabled, open] + ); + + return ( + + + + + + + ); +} + function useBookInfo(id) { const [state, setState] = React.useState();