Skip to content

Commit

Permalink
temp: trying to get hook to work
Browse files Browse the repository at this point in the history
  • Loading branch information
ilee2u committed Dec 13, 2024
1 parent 07ce69a commit d38ce63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
23 changes: 5 additions & 18 deletions src/components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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(() => {
Expand Down Expand Up @@ -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)

Check warning on line 94 in src/components/Sidebar/index.jsx

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement

Check failure on line 94 in src/components/Sidebar/index.jsx

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 94 in src/components/Sidebar/index.jsx

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

if (auditTrialDaysRemaining > 1) {
const irtl = new Intl.RelativeTimeFormat({ style: 'long' });
return (
<div>
Your trial ends {irtl.format(auditTrialDaysRemaining, 'day')}. <a target="_blank" href={upgradeURL} rel="noreferrer">Upgrade</a> for full access to Xpert.
Your trial ends {irtl.format(auditTrialDaysRemaining, 'day')}. <a target="_blank" href={upgradeUrl} rel="noreferrer">Upgrade</a> for full access to Xpert.
</div>
);
} if (auditTrialDaysRemaining === 1) {
return (
<div>
Your trial ends today! <a target="_blank" href={upgradeURL} rel="noreferrer">Upgrade</a> for full access to Xpert.
Your trial ends today! <a target="_blank" href={upgradeUrl} rel="noreferrer">Upgrade</a> for full access to Xpert.
</div>
);
}
// TODO: Show the upgrade screen instead of this banner, to be done in future ticket
return (
<div>
Your trial has expired. <a target="_blank" href={upgradeURL} rel="noreferrer">Upgrade</a> for full access to Xpert.
Your trial has expired. <a target="_blank" href={upgradeUrl} rel="noreferrer">Upgrade</a> for full access to Xpert.
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-course-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }; }
Expand All @@ -26,6 +25,7 @@ export default function useCourseUpgrade() {
auditTrialDaysRemaining = Math.ceil((auditTrialExpirationDate - Date.now()) / millisecondsInOneDay);

auditTrialExpired = auditTrialDaysRemaining < 0;
console.log({upgradeUrl}, {auditTrialDaysRemaining})

Check warning on line 28 in src/hooks/use-course-upgrade.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement

Check failure on line 28 in src/hooks/use-course-upgrade.js

View workflow job for this annotation

GitHub Actions / test

A space is required after '{'

Check failure on line 28 in src/hooks/use-course-upgrade.js

View workflow job for this annotation

GitHub Actions / test

A space is required before '}'

Check failure on line 28 in src/hooks/use-course-upgrade.js

View workflow job for this annotation

GitHub Actions / test

A space is required after '{'

Check failure on line 28 in src/hooks/use-course-upgrade.js

View workflow job for this annotation

GitHub Actions / test

A space is required before '}'

Check failure on line 28 in src/hooks/use-course-upgrade.js

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
}

return {
Expand Down

0 comments on commit d38ce63

Please sign in to comment.