From cdb0f48f089df53fb296ffe6c87bfe850e669a7b Mon Sep 17 00:00:00 2001 From: Simon Chen Date: Wed, 25 Oct 2023 13:29:07 -0400 Subject: [PATCH] feat!: upsell through a course cert preview pop up Even if the learner is enrolled in the course as a audit learner, each course cards would show a link that, once clicked upon, will pop a modal with verified cert preview and upgrade button --- .env | 2 +- .env.development | 1 + .../CertificatePreviewModal/hooks.js | 29 +++++++++++ .../CertificatePreviewModal/index.jsx | 48 +++++++++++++++++++ .../CertificatePreviewModal/messages.js | 12 +++++ .../components/CourseCardDetails/hooks.js | 2 + .../components/CourseCardDetails/index.jsx | 40 ++++++++++------ .../components/CourseCardMenu/index.jsx | 7 +++ .../WidgetContainers/AppWrapper/index.jsx | 14 +++--- src/data/redux/app/reducer.js | 5 ++ src/data/redux/app/selectors/appSelectors.js | 6 +++ .../redux/app/selectors/simpleSelectors.js | 1 + src/data/redux/hooks/app.js | 8 ++++ 13 files changed, 152 insertions(+), 23 deletions(-) create mode 100644 src/containers/CertificatePreviewModal/hooks.js create mode 100644 src/containers/CertificatePreviewModal/index.jsx create mode 100644 src/containers/CertificatePreviewModal/messages.js diff --git a/.env b/.env index 2291ec6..deb1b16 100644 --- a/.env +++ b/.env @@ -41,4 +41,4 @@ ACCOUNT_PROFILE_URL='' ENABLE_NOTICES='' CAREER_LINK_URL='' OPTIMIZELY_FULL_STACK_SDK_KEY='' -EXPERIMENT_08_23_VAN_PAINTED_DOOR=true +EXPERIMENT_08_23_VAN_PAINTED_DOOR='true' diff --git a/.env.development b/.env.development index 78e4c40..c1a60a8 100644 --- a/.env.development +++ b/.env.development @@ -48,3 +48,4 @@ ACCOUNT_PROFILE_URL='http://localhost:1995' ENABLE_NOTICES='' CAREER_LINK_URL='' OPTIMIZELY_FULL_STACK_SDK_KEY='' +EXPERIMENT_08_23_VAN_PAINTED_DOOR=true diff --git a/src/containers/CertificatePreviewModal/hooks.js b/src/containers/CertificatePreviewModal/hooks.js new file mode 100644 index 0000000..6558b22 --- /dev/null +++ b/src/containers/CertificatePreviewModal/hooks.js @@ -0,0 +1,29 @@ +import { getConfig } from '@edx/frontend-platform'; +import { useIntl } from '@edx/frontend-platform/i18n'; + +import { reduxHooks } from 'hooks'; +import messages from './messages'; + +export const useCertificatePreviewData = () => { + const { formatMessage } = useIntl(); + + const selectedCardId = reduxHooks.useCertificatePreviewData().cardId; + + const { courseId } = reduxHooks.useCardCourseRunData(selectedCardId) || {}; + + const courseTitle = courseId; + const header = formatMessage(messages.previewTitle, { courseTitle }); + + const closePreviewModal = reduxHooks.useUpdateCertificatePreviewModalCallback(null); + + const getCertificatePreviewUrl = () => `${getConfig().LMS_BASE_URL}/certificates/upsell/course/${courseId}`; + + return { + showModal: selectedCardId != null, + header, + closePreviewModal, + getCertificatePreviewUrl, + }; +}; + +export default useCertificatePreviewData; diff --git a/src/containers/CertificatePreviewModal/index.jsx b/src/containers/CertificatePreviewModal/index.jsx new file mode 100644 index 0000000..3499c9b --- /dev/null +++ b/src/containers/CertificatePreviewModal/index.jsx @@ -0,0 +1,48 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { + ModalDialog, +} from '@edx/paragon'; +import { UpgradeButton } from '../CourseCard/components/CourseCardActions/UpgradeButton'; +import useCertificatePreviewData from './hooks'; + +export const CertificatePreviewModal = ({ + cardId, +}) => { + const { + showModal, + header, + closePreviewModal, + getCertificatePreviewUrl, + } = useCertificatePreviewData(); + + return ( + +

{header}

+
+