From d38ce630a72c8aae5403b58d88132bac9289e8bd Mon Sep 17 00:00:00 2001 From: ilee2u Date: Fri, 13 Dec 2024 15:12:23 -0500 Subject: [PATCH] temp: trying to get hook to work --- src/components/Sidebar/index.jsx | 23 +++++------------------ src/hooks/use-course-upgrade.js | 2 +- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/components/Sidebar/index.jsx b/src/components/Sidebar/index.jsx index 70292ca8..245ec234 100644 --- a/src/components/Sidebar/index.jsx +++ b/src/components/Sidebar/index.jsx @@ -8,15 +8,13 @@ import { } from '@openedx/paragon'; import { Close } from '@openedx/paragon/icons'; -import { useModel } from '@src/generic/model-store'; // eslint-disable-line import/no-unresolved - import showSurvey from '../../utils/surveyMonkey'; import APIError from '../APIError'; import ChatBox from '../ChatBox'; import Disclosure from '../Disclosure'; import MessageForm from '../MessageForm'; -import { useCourseUpgrade, useTrackEvent } from '../../hooks'; +import { useCourseUpgrade } from '../../hooks'; import { ReactComponent as XpertLogo } from '../../assets/xpert-logo.svg'; import './Sidebar.scss'; @@ -37,16 +35,6 @@ const Sidebar = ({ const chatboxContainerRef = useRef(null); - const courseHomeMeta = useModel('courseHomeMeta', courseId); - const { - verifiedMode, - } = courseHomeMeta; - - const course = useModel('coursewareMeta', courseId); - const { - offer, - } = course; - // this use effect is intended to scroll to the bottom of the chat window, in the case // that a message is larger than the chat window height. useEffect(() => { @@ -103,27 +91,26 @@ const Sidebar = ({ show all the audit trial data, expired or not. */ const getDaysRemainingMessage = () => { - - const upgradeURL = offer ? offer.upgradeUrl : verifiedMode.upgradeUrl; + console.log("auditTrialDaysRemaining", auditTrialDaysRemaining) if (auditTrialDaysRemaining > 1) { const irtl = new Intl.RelativeTimeFormat({ style: 'long' }); return (
- Your trial ends {irtl.format(auditTrialDaysRemaining, 'day')}. Upgrade for full access to Xpert. + Your trial ends {irtl.format(auditTrialDaysRemaining, 'day')}. Upgrade for full access to Xpert.
); } if (auditTrialDaysRemaining === 1) { return (
- Your trial ends today! Upgrade for full access to Xpert. + Your trial ends today! Upgrade for full access to Xpert.
); } // TODO: Show the upgrade screen instead of this banner, to be done in future ticket return (
- Your trial has expired. Upgrade for full access to Xpert. + Your trial has expired. Upgrade for full access to Xpert.
); }; diff --git a/src/hooks/use-course-upgrade.js b/src/hooks/use-course-upgrade.js index f5544890..0f4b9f87 100644 --- a/src/hooks/use-course-upgrade.js +++ b/src/hooks/use-course-upgrade.js @@ -13,7 +13,6 @@ export default function useCourseUpgrade() { auditTrialLengthDays, auditTrial, } = useSelector(state => state.learningAssistant); - const upgradeUrl = offer?.upgradeUrl || verifiedMode?.upgradeUrl; if (!isUpgradeEligible || !upgradeUrl) { return { upgradeable: false }; } @@ -26,6 +25,7 @@ export default function useCourseUpgrade() { auditTrialDaysRemaining = Math.ceil((auditTrialExpirationDate - Date.now()) / millisecondsInOneDay); auditTrialExpired = auditTrialDaysRemaining < 0; + console.log({upgradeUrl}, {auditTrialDaysRemaining}) } return {