Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bugs related to variant release #1307

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -143,7 +142,7 @@ const AssignmentModalContent = ({
/>
</h4>
<AssignmentModalSummary
course={course}
courseRun={courseRun}
learnerEmails={learnerEmails}
assignmentAllocationMetadata={assignmentAllocationMetadata}
/>
Expand Down Expand Up @@ -207,6 +206,7 @@ AssignmentModalContent.propTypes = {
courseRun: PropTypes.shape({
enrollBy: PropTypes.string,
start: PropTypes.string,
contentPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}).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 @@ -13,13 +13,13 @@ import AssignmentModalSummaryErrorState from './AssignmentModalSummaryErrorState
const AssignmentModalSummaryContents = ({
hasLearnerEmails,
learnerEmails,
course,
courseRun,
hasInputValidationError,
}) => {
if (hasLearnerEmails) {
return (
<AssignmentModalSummaryLearnerList
course={course}
courseRun={courseRun}
learnerEmails={learnerEmails}
/>
);
Expand All @@ -31,7 +31,7 @@ const AssignmentModalSummaryContents = ({
};

const AssignmentModalSummary = ({
course,
courseRun,
learnerEmails,
assignmentAllocationMetadata,
}) => {
Expand Down Expand Up @@ -66,7 +66,7 @@ const AssignmentModalSummary = ({
<AssignmentModalSummaryContents
learnerEmails={learnerEmails}
hasLearnerEmails={hasLearnerEmails}
course={course}
courseRun={courseRun}
hasInputValidationError={!isValidInput}
/>
</Card.Section>
Expand Down Expand Up @@ -103,12 +103,16 @@ const AssignmentModalSummary = ({
AssignmentModalSummaryContents.propTypes = {
hasLearnerEmails: PropTypes.bool.isRequired,
learnerEmails: PropTypes.arrayOf(PropTypes.string).isRequired,
course: PropTypes.shape().isRequired, // pass-thru prop to child component(s)
courseRun: PropTypes.shape({
contentPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}).isRequired, // pass-thru prop to child component(s)
hasInputValidationError: PropTypes.bool.isRequired,
};

AssignmentModalSummary.propTypes = {
course: PropTypes.shape().isRequired, // pass-thru prop to child component(s)
courseRun: PropTypes.shape({
contentPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}).isRequired, // pass-thru prop to child component(s)
learnerEmails: PropTypes.arrayOf(PropTypes.string).isRequired,
assignmentAllocationMetadata: PropTypes.shape({
isValidInput: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { v4 as uuidv4 } from 'uuid';
import {
Button, Stack, Icon,
} from '@openedx/paragon';
import { Button, Icon, Stack } from '@openedx/paragon';
import { Person } from '@openedx/paragon/icons';
import { useIntl } from '@edx/frontend-platform/i18n';

import { MAX_INITIAL_LEARNER_EMAILS_DISPLAYED_COUNT, hasLearnerEmailsSummaryListTruncation } from '../cards/data';
import { hasLearnerEmailsSummaryListTruncation, MAX_INITIAL_LEARNER_EMAILS_DISPLAYED_COUNT } from '../cards/data';
import { formatPrice } from '../data';

const AssignmentModalSummaryLearnerList = ({
course,
courseRun,
learnerEmails,
}) => {
const [isTruncated, setIsTruncated] = useState(hasLearnerEmailsSummaryListTruncation(learnerEmails));
Expand Down Expand Up @@ -53,7 +52,7 @@ const AssignmentModalSummaryLearnerList = ({
</Stack>
</div>
<span className="ml-auto">
{course.formattedPrice}
{formatPrice(courseRun.contentPrice)}
</span>
</div>
</li>
Expand All @@ -74,8 +73,8 @@ const AssignmentModalSummaryLearnerList = ({
};

AssignmentModalSummaryLearnerList.propTypes = {
course: PropTypes.shape({
formattedPrice: PropTypes.string.isRequired,
courseRun: PropTypes.shape({
contentPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}).isRequired,
learnerEmails: PropTypes.arrayOf(PropTypes.string).isRequired,
};
Expand Down
14 changes: 7 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,19 @@
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
if (isDateBeforeToday(enrollBy) && isLateRedemptionAllowed) {
const lateEnrollmentCutoff = dayjs().subtract(LATE_ENROLLMENTS_BUFFER_DAYS, 'days');
isEligibleForEnrollment = dayjs(enrollBy).isAfter(lateEnrollmentCutoff);

Check warning on line 668 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L667-L668

Added lines #L667 - L668 were not covered by tests
return isLateEnrollmentEligible && isEligibleForEnrollment;
}
}
// General courseware filter
return isActive && isEligibleForEnrollment;
Expand Down