diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9fd13bfd4..4ba573269 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,9 +8,10 @@ jobs: uses: actions/checkout@v2 - name: "Setup NVM" - uses: dcodeIO/setup-node-nvm@master + uses: actions/setup-node@v3 with: - node-version: v16.20.2 + node-version-file: .nvmrc + cache: yarn - name: "Setup environment" run: ./script/setup diff --git a/src/app/pages/details/common/featured-resources/featured-resources.js b/src/app/pages/details/common/featured-resources/featured-resources.js deleted file mode 100644 index 9a99d055a..000000000 --- a/src/app/pages/details/common/featured-resources/featured-resources.js +++ /dev/null @@ -1,51 +0,0 @@ -import React from 'react'; -import ResourceBoxes from '../resource-box/resource-boxes'; -import {FormattedMessage} from 'react-intl'; -import './featured-resources.scss'; - -function FeaturedResources({headline, resources, ...props}) { - const modResources = resources.map((res) => { - const storageKey = `featured-resource-${res.heading}`; - const seenTimes = 1 + Number(window.localStorage[storageKey] || 0); - const model = Object.assign({ - isNew: seenTimes <= 3, - onClick: () => { - window.localStorage[storageKey] = 5; - model.isNew = false; - } - }, res); - - window.localStorage[storageKey] = seenTimes; - - return model; - }); - - return ( -
-
- {headline} -
-
- -
-
- ); -} - -export default function FeaturedResourcesSection({header, models, ...props}) { - return ( -
-
- -
-
-
- -
-
-
- ); -} diff --git a/src/app/pages/details/common/featured-resources/featured-resources.tsx b/src/app/pages/details/common/featured-resources/featured-resources.tsx new file mode 100644 index 000000000..e4d2200ad --- /dev/null +++ b/src/app/pages/details/common/featured-resources/featured-resources.tsx @@ -0,0 +1,64 @@ +import React from 'react'; +import ResourceBoxes, {ResourceModel} from '../resource-box/resource-boxes'; +import {FormattedMessage} from 'react-intl'; +import './featured-resources.scss'; + +type ResourcesProps = { + header: string; + models: ResourceModel[]; + 'data-analytics-content-list': string; +}; + +function FeaturedResources({header, models, ...props}: ResourcesProps) { + const modResources = models.map((res) => { + const storageKey = `featured-resource-${res.heading}`; + const seenTimes = 1 + Number(window.localStorage[storageKey] || 0); + const model = Object.assign( + { + isNew: seenTimes <= 3 + // There was an onClick defined here that nothing used + }, + res + ); + + window.localStorage[storageKey] = seenTimes; + + return model; + }); + + return ( +
+
{header}
+
+ +
+
+ ); +} + +export default function FeaturedResourcesSection({ + header, + models, + ...props +}: ResourcesProps) { + return ( +
+
+ +
+
+
+ +
+
+
+ ); +} diff --git a/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-other.tsx b/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-other.tsx index 490ae5b88..5a4ab56e9 100644 --- a/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-other.tsx +++ b/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-other.tsx @@ -17,7 +17,7 @@ export default function GiveBeforeOther({ close: () => void; data: DonationPopupData; track?: string; - variant?: string; + variant: string; onDownload?: (event: React.MouseEvent) => void; id?: string; }) { diff --git a/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-pdf.tsx b/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-pdf.tsx index e55d066d6..f4e6f4675 100644 --- a/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-pdf.tsx +++ b/src/app/pages/details/common/get-this-title-files/give-before-pdf/give-before-pdf.tsx @@ -62,7 +62,7 @@ function GiveBeforePdfAfterConditionals({ }: { onThankYouClick: ReturnType['onThankYouClick']; link: string; - track: string | undefined; + track?: string; data: DonationPopupData; close: () => void; onDownload?: (event: React.MouseEvent) => void; diff --git a/src/app/pages/details/common/get-this-title-files/give-before-pdf/thank-you-form.js b/src/app/pages/details/common/get-this-title-files/give-before-pdf/thank-you-form.tsx similarity index 54% rename from src/app/pages/details/common/get-this-title-files/give-before-pdf/thank-you-form.js rename to src/app/pages/details/common/get-this-title-files/give-before-pdf/thank-you-form.tsx index 9aef197a9..a7157dbc6 100644 --- a/src/app/pages/details/common/get-this-title-files/give-before-pdf/thank-you-form.js +++ b/src/app/pages/details/common/get-this-title-files/give-before-pdf/thank-you-form.tsx @@ -2,54 +2,67 @@ import React from 'react'; import useUserContext from '~/contexts/user'; import trackLink from '../../track-link'; import './thank-you-form.scss'; +import {TrackedMouseEvent} from '~/components/shell/router-helpers/use-link-handler'; function FormWithAfterSubmit({ afterSubmit, responseId = 'form-response', children, - onSubmit: firstOnSubmit, ...formProps -}) { - const iframeRef = React.useRef(); +}: React.PropsWithChildren< + { + afterSubmit: () => void; + responseId?: string; + } & React.FormHTMLAttributes +>) { + const iframeRef = React.useRef(null); const onSubmit = React.useCallback( - (event) => { - if (firstOnSubmit) { - firstOnSubmit(event); - if (event.defaultPrevented) { - return; - } - } + () => { const iframe = iframeRef.current; const runAfterSubmit = () => { afterSubmit(); - iframe.removeEventListener('load', runAfterSubmit); + iframe?.removeEventListener('load', runAfterSubmit); }; - iframe.addEventListener('load', runAfterSubmit); + iframe?.addEventListener('load', runAfterSubmit); }, - [firstOnSubmit, afterSubmit] + [afterSubmit] ); return (