Skip to content

Commit

Permalink
fix: bugs related to variant release
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed Sep 18, 2024
1 parent 5619bad commit f5e7171
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
import React from 'react';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import dayjs from 'dayjs';
import { ASSIGNMENT_ENROLLMENT_DEADLINE, DATETIME_FORMAT, getNormalizedEnrollByDate } from '../data';
import { ASSIGNMENT_ENROLLMENT_DEADLINE, DATETIME_FORMAT } from '../data';
import EVENT_NAMES from '../../../eventTracking';

const AssignmentAllocationHelpCollapsibles = ({ enterpriseId, courseRun }) => {
const normalizedEnrollByDate = getNormalizedEnrollByDate(courseRun);
const enrollByDate = normalizedEnrollByDate
? dayjs(normalizedEnrollByDate).format(DATETIME_FORMAT)
: null;
const enrollByDate = dayjs(courseRun.enrollBy).format(DATETIME_FORMAT);
return (
<Stack gap={1}>
<Collapsible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ const AssignmentModalContent = ({
const [emailAddressesInputValue, setEmailAddressesInputValue] = useState('');
const [assignmentAllocationMetadata, setAssignmentAllocationMetadata] = useState({});
const intl = useIntl();
// TODO: as part of fixed price, this would need to extract the contentPrice from courseRun, ENT-9394
const { contentPrice } = course.normalizedMetadata;
const { contentPrice } = courseRun;
const handleEmailAddressInputChange = (e) => {
const inputValue = e.target.value;
setEmailAddressesInputValue(inputValue);
Expand Down Expand Up @@ -207,6 +206,7 @@ AssignmentModalContent.propTypes = {
courseRun: PropTypes.shape({
enrollBy: PropTypes.string,
start: PropTypes.string,
contentPrice: PropTypes.string,
}).isRequired,
onEmailAddressesChange: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Card, Stack, Icon } from '@openedx/paragon';
import { Card, Icon, Stack } from '@openedx/paragon';
import { Error } from '@openedx/paragon/icons';

import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
import { formatPrice } from '../data';
import AssignmentModalSummaryEmptyState from './AssignmentModalSummaryEmptyState';
import AssignmentModalSummaryLearnerList from './AssignmentModalSummaryLearnerList';
Expand All @@ -30,6 +30,7 @@ const AssignmentModalSummaryContents = ({
return <AssignmentModalSummaryEmptyState />;
};

// TODO: Pass course runs to take into account hte individual run content_price
const AssignmentModalSummary = ({
course,
learnerEmails,
Expand Down
15 changes: 8 additions & 7 deletions src/components/learner-credit-management/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,19 +655,20 @@ export const getAssignableCourseRuns = ({ courseRuns, subsidyExpirationDatetime,
upgradeDeadline: dayjs.unix(courseRun.upgradeDeadline).toISOString(),
}));
const assignableCourseRunsFilter = ({
enrollBy, isActive, hasEnrollBy = false, isLateEnrollmentEligible = false,
enrollBy, isActive, hasEnrollBy, isLateEnrollmentEligible,
}) => {
let isEligibleForEnrollment = true;
if (hasEnrollBy) {
isEligibleForEnrollment = dayjs(enrollBy).isBefore(
minimumEnrollByDateFromToday({ subsidyExpirationDatetime }),
);
}
// Late redemption filter
if (isDateBeforeToday(enrollBy) && isLateRedemptionAllowed) {
const lateEnrollmentCutoff = dayjs().subtract(LATE_ENROLLMENTS_BUFFER_DAYS, 'days');
isEligibleForEnrollment = dayjs(enrollBy).isAfter(lateEnrollmentCutoff);
return isLateEnrollmentEligible && isEligibleForEnrollment;
// Late redemption filter
// TODO: Fallback to enrollmentStart if no enrollBy field (surface in ALG)
if (isDateBeforeToday(enrollBy) && isLateRedemptionAllowed) {
const lateEnrollmentCutoff = dayjs().subtract(LATE_ENROLLMENTS_BUFFER_DAYS, 'days');
isEligibleForEnrollment = dayjs(enrollBy).isAfter(lateEnrollmentCutoff);
return isLateEnrollmentEligible && isEligibleForEnrollment;
}
}
// General courseware filter
return isActive && isEligibleForEnrollment;
Expand Down

0 comments on commit f5e7171

Please sign in to comment.