Skip to content

Commit

Permalink
Use different Give links for different download types
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed Aug 14, 2023
1 parent d2e6259 commit 1977cc4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {faHeart} from '@fortawesome/free-solid-svg-icons/faHeart';
import ThankYou from './thank-you-form';
import {enroll} from '@openstax/experiments';
import './give-before-pdf.scss';
import giveLinks from './give-links';

function Downloading({data}) {
return (
Expand Down Expand Up @@ -47,14 +48,16 @@ function GiveBeforePdfAfterConditionals({onThankYouClick, link, data, close, onD
[close, onDownload]
);

const [controlLink, alternateLink] = giveLinks();
const donationExperiment = enroll({
name: 'Donation Experiment 2023',
variants: [
// eslint-disable-next-line camelcase
{name: 'control', header_subtitle: data.header_subtitle},
{name: 'control', header_subtitle: data.header_subtitle, giveLink: controlLink},
{name: 'public good',
// eslint-disable-next-line camelcase
header_subtitle: 'Join us in sustaining OpenStax as a public good for years to come by giving today.'
header_subtitle: 'Join us in sustaining OpenStax as a public good for years to come by giving today.',
giveLink: alternateLink
}
]
});
Expand All @@ -80,7 +83,7 @@ function GiveBeforePdfAfterConditionals({onThankYouClick, link, data, close, onD
</p>
<div className="button-row">
<a
href={data.give_link}
href={donationExperiment.giveLink}
className="btn primary"
onClick={OpenGiveInNewWindow}
data-nudge-action="interacted"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import {useLocation} from 'react-router-dom';

// Two Give link options for each of: PDF downloads, Instructor resources, Student resources
export default function useGiveLinks() {
const {search} = useLocation();

return React.useMemo(() => getLinks(search), [search]);
}

function getLinks(search: string) {
if (search.includes('Instructor')) {
return [
'https://riceconnect.rice.edu/donation/support-openstax-instructor-resources',
'https://riceconnect.rice.edu/donation/support-openstax-instructor-resources-b'
];
}
if (search.includes('Student')) {
return [
'https://riceconnect.rice.edu/donation/support-openstax-student-resources',
'https://riceconnect.rice.edu/donation/support-openstax-student-resources-b'
];
}
return [
'https://riceconnect.rice.edu/donation/support-openstax-subject',
'https://riceconnect.rice.edu/donation/support-openstax-subject-b'
];
}

0 comments on commit 1977cc4

Please sign in to comment.