Skip to content

Commit

Permalink
Pass data-track info to give dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed Nov 15, 2023
1 parent aa35591 commit de2d972
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import './give-before-pdf.scss';

export default function GiveBeforePdf({
link,
track,
close,
data,
onDownload
}: {
link: string;
track?: string;
close: () => void;
data: DonationPopupData;
onDownload: () => void;
Expand All @@ -32,7 +34,7 @@ export default function GiveBeforePdf({

return (
<GiveBeforePdfAfterConditionals
{...{onThankYouClick, link, data, close, onDownload}}
{...{onThankYouClick, link, track, data, close, onDownload}}
/>
);
}
Expand All @@ -49,12 +51,14 @@ function Downloading({data}: {data: DonationPopupData}) {
function GiveBeforePdfAfterConditionals({
onThankYouClick,
link,
track,
data,
close,
onDownload
}: {
onThankYouClick: ReturnType<typeof useOnThankYouClick>['onThankYouClick'];
link: string;
track: string | undefined;
data: DonationPopupData;
close: () => void;
onDownload: (event: React.MouseEvent) => void;
Expand Down Expand Up @@ -88,7 +92,10 @@ function GiveBeforePdfAfterConditionals({
<h1>{data.download_ready}</h1>
<hr />
<CommonElements onThankYouClick={onThankYouClick} data={data} />
<a href={link} onClick={closeAfterDelay} className='btn go-to'>
<a
href={link}
{...(track ? {'data-track': track} : {})}
onClick={closeAfterDelay} className='btn go-to'>
Go to your file
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export default function useGiveDialog() {
const GiveDialog = React.useCallback(
({
link,
track,
onDownload,
variant
}: {
link: string;
track?: string;
onDownload?: (
e: React.MouseEvent<HTMLAnchorElement, MouseEvent>
) => void;
Expand All @@ -25,7 +27,7 @@ export default function useGiveDialog() {

return (
<Dialog>
<Variant {...{link, close, data, onDownload}} />
<Variant {...{link, track, close, data, onDownload}} />
</Dialog>
);
},
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/details/common/resource-box/left-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function LeftButton({model}: {model: LeftContentModelType & LinkIsSet}) {
{isDownload && (
<GiveDialog
link={model.link.url}
track={model.heading}
onDownload={
trackDownloadClick as unknown as (
e: React.MouseEvent
Expand Down

0 comments on commit de2d972

Please sign in to comment.