Compare commits
1 Commits
master
...
alangsto/e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a5687bfe3 |
@@ -2,9 +2,11 @@ import { createPortal } from 'react-dom';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { Xpert } from '@edx/frontend-lib-learning-assistant';
|
import { Xpert } from '@edx/frontend-lib-learning-assistant';
|
||||||
|
import { hasActiveExamAttempt } from '@edx/frontend-lib-special-exams';
|
||||||
import { injectIntl } from '@edx/frontend-platform/i18n';
|
import { injectIntl } from '@edx/frontend-platform/i18n';
|
||||||
|
|
||||||
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
|
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
const Chat = ({
|
const Chat = ({
|
||||||
enabled,
|
enabled,
|
||||||
@@ -31,6 +33,13 @@ const Chat = ({
|
|||||||
'unpaid-bootcamp',
|
'unpaid-bootcamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const [hasActiveAttempt, setHasActiveAttempt] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setHasActiveAttempt(hasActiveExamAttempt());
|
||||||
|
console.log(hasActiveExamAttempt());
|
||||||
|
}, [hasActiveExamAttempt, setHasActiveAttempt]);
|
||||||
|
|
||||||
const isEnrolled = (
|
const isEnrolled = (
|
||||||
enrollmentMode !== null
|
enrollmentMode !== null
|
||||||
&& enrollmentMode !== undefined
|
&& enrollmentMode !== undefined
|
||||||
@@ -39,6 +48,7 @@ const Chat = ({
|
|||||||
|
|
||||||
const shouldDisplayChat = (
|
const shouldDisplayChat = (
|
||||||
enabled
|
enabled
|
||||||
|
&& !hasActiveAttempt
|
||||||
&& (isEnrolled || isStaff) // display only to enrolled or staff
|
&& (isEnrolled || isStaff) // display only to enrolled or staff
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user