AA-264 mfe courseware reset dates (#165)

- add toast display after successful reset of dates via banner.
This commit is contained in:
Nick
2020-08-06 15:20:53 -04:00
committed by GitHub
parent ad74b2295b
commit 9a315aa29d
10 changed files with 305 additions and 28 deletions

View File

@@ -5,6 +5,7 @@ import React, {
useState,
useLayoutEffect,
} from 'react';
import { useDispatch } from 'react-redux';
import PropTypes from 'prop-types';
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
@@ -12,6 +13,8 @@ import messages from './messages';
import BookmarkButton from '../bookmark/BookmarkButton';
import { useModel } from '../../../generic/model-store';
import PageLoading from '../../../generic/PageLoading';
import { resetDeadlines } from '../../../course-home/data/thunks';
import { fetchCourse } from '../../data/thunks';
const LockPaywall = React.lazy(() => import('./lock-paywall'));
@@ -64,6 +67,8 @@ function Unit({
contentTypeGatingEnabled,
} = course;
const dispatch = useDispatch();
// Do not remove this hook. See function description.
useLoadBearingHook(id);
@@ -130,6 +135,13 @@ function Unit({
height={iframeHeight}
scrolling="no"
referrerPolicy="origin"
onLoad={() => {
window.onmessage = function (e) {
if (e.data === 'reset_dates') {
dispatch(resetDeadlines(courseId, fetchCourse));
}
};
}}
/>
</div>
</div>