diff --git a/src/course-home/data/api.js b/src/course-home/data/api.js index 17adeb87..0c1ead2a 100644 --- a/src/course-home/data/api.js +++ b/src/course-home/data/api.js @@ -201,6 +201,7 @@ export async function getOutlineTabData(courseId) { resumeCourse, verifiedMode, welcomeMessageHtml, + timeOffsetMillis: 0, }; } diff --git a/src/course-home/outline-tab/widgets/UpgradeCard.jsx b/src/course-home/outline-tab/widgets/UpgradeCard.jsx index fd753fd8..2635e8b3 100644 --- a/src/course-home/outline-tab/widgets/UpgradeCard.jsx +++ b/src/course-home/outline-tab/widgets/UpgradeCard.jsx @@ -1,22 +1,223 @@ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; +import { faCheck } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { sendTrackEvent, sendTrackingLogEvent } from '@edx/frontend-platform/analytics'; -import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; -import { Button } from '@edx/paragon'; +import { FormattedDate, FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { getConfig } from '@edx/frontend-platform'; -import messages from '../messages'; import { useModel } from '../../../generic/model-store'; import { UpgradeButton } from '../../../generic/upgrade-button'; -import VerifiedCert from '../../../generic/assets/edX_certificate.png'; -function UpgradeCard({ courseId, intl, onLearnMore }) { +function UpsellNoFBECardContent(){ + return ( + + ); +} + +function UpsellFBEFarAwayCardContent() { + return ( + + ); +} + +function UpsellFBESoonCardContent({accessExpirationDate, timezoneFormatArgs}) { + return ( +
+

+ including any progress), + date: (), + }} + /> +

+

+ benefits of upgrading), + }} + /> +

+
+ ); +} + +UpsellFBESoonCardContent.propTypes = { + accessExpirationDate: PropTypes.PropTypes.instanceOf(Date).isRequired, + timezoneFormatArgs: PropTypes.shape({ + timeZone: PropTypes.string, + }) +}; + +function ExpirationCountdown({hoursToExpiration}){ + let expirationText; + console.log(hoursToExpiration) + + if(hoursToExpiration >= 24){ + expirationText = + } else if (hoursToExpiration >= 1){ + expirationText= + } else { + expirationText = + } + return(
{expirationText}
) +} + +ExpirationCountdown.propTypes = { + hoursToExpiration: PropTypes.number.isRequired, +}; + +function AccessExpirationDateBanner({accessExpirationDate, timezoneFormatArgs}){ + return ( +
+ ), + }} + /> +
+ ); +} + +AccessExpirationDateBanner.propTypes = { + accessExpirationDate: PropTypes.PropTypes.instanceOf(Date).isRequired, + timezoneFormatArgs: PropTypes.shape({ + timeZone: PropTypes.string, + }) +}; + +function UpgradeCard({ courseId }) { const { org } = useModel('courseHomeMeta', courseId); const { offer, verifiedMode, + accessExpiration, + datesBannerInfo: { + contentTypeGatingEnabled, + }, + datesWidget: { + userTimezone, + }, + timeOffsetMillis, } = useModel('outline', courseId); + const timezoneFormatArgs = userTimezone ? { timeZone: userTimezone } : {}; + const correctedTime = new Date(Date.now() + timeOffsetMillis); + + if (!verifiedMode) { return null; } @@ -55,41 +256,90 @@ function UpgradeCard({ courseId, intl, onLearnMore }) { }); }; - return ( -
-

{intl.formatMessage(messages.upgradeTitle)}

-
-
- {intl.formatMessage(messages.certAlt)} + + expirationBanner = + upsellMessage = + offerCode =
+ {offer.code}), + }} + /> +
+ + } else { + const accessExpirationDate = new Date(accessExpiration.expirationDate) + const hoursToAccessExpiration = Math.floor((accessExpirationDate - correctedTime) /1000/ 60 /60) + + if(hoursToAccessExpiration >= (7*24)) { + upgradeCardHeaderText = -
-
-
- - {onLearnMore && ( -
- -
- )} -
-
+ expirationBanner = + upsellMessage = + } else { // more urgent messaging if there's less than 7 days left + upgradeCardHeaderText = + expirationBanner = + upsellMessage = + } + } + } else { //FBE is turned off + upgradeCardHeaderText = + upsellMessage = + } + + + + return ( +
+

+ {upgradeCardHeaderText} +

+ {expirationBanner} +
+ {upsellMessage}
+ + {offerCode}
); } diff --git a/src/course-home/outline-tab/widgets/UpgradeCard.scss b/src/course-home/outline-tab/widgets/UpgradeCard.scss index 5f369519..2fa28631 100644 --- a/src/course-home/outline-tab/widgets/UpgradeCard.scss +++ b/src/course-home/outline-tab/widgets/UpgradeCard.scss @@ -2,3 +2,19 @@ border: 1px solid $dark-500; border-top: 5px solid $dark-500; } + +.upsell-warning{ + background-color: #FCF1F4; +} + +.upsell-warning-light{ + background-color: #FFFAED;; +} + +.discount-info { + border-top: 1px solid rgba(0, 0, 0, 0.125); +} + +.inline-link-underline { + text-decoration: underline; +} \ No newline at end of file