Skip to content

Commit

Permalink
feat: surface time in the enroll-by date column (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 authored Sep 18, 2024
1 parent 6c82806 commit 329fae8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import PropTypes from 'prop-types';
import {
Icon, IconButtonWithTooltip, Stack,
} from '@openedx/paragon';
import { Icon, IconButtonWithTooltip, Stack } from '@openedx/paragon';
import { Warning } from '@openedx/paragon/icons';
import { defineMessages, useIntl } from '@edx/frontend-platform/i18n';
import { ENROLL_BY_DATE_DAYS_THRESHOLD, formatDate } from './data';
import { DATETIME_FORMAT, ENROLL_BY_DATE_DAYS_THRESHOLD, formatDate } from './data';
import { isTodayWithinDateThreshold } from '../../utils';

const messages = defineMessages({
Expand Down Expand Up @@ -33,7 +31,7 @@ const ExpiringIconButtonWithTooltip = () => {
const AssignmentEnrollByDateCell = ({ row }) => {
const { original: { earliestPossibleExpiration: { date } } } = row;

const formattedEnrollByDate = formatDate(date);
const formattedEnrollByDate = formatDate(date, DATETIME_FORMAT);
const isAssignmentExpiringSoon = isTodayWithinDateThreshold({
days: ENROLL_BY_DATE_DAYS_THRESHOLD,
date,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import React from 'react';
import {
Stack,
Icon,
IconButtonWithTooltip,
} from '@openedx/paragon';
import { Icon, IconButtonWithTooltip, Stack } from '@openedx/paragon';
import { InfoOutline } from '@openedx/paragon/icons';
import { defineMessages, useIntl } from '@edx/frontend-platform/i18n';

Expand All @@ -15,7 +11,7 @@ const messages = defineMessages({
},
headerTooltipContent: {
id: 'lcm.budget.detail.page.assignments.table.columns.enroll-by-date.header.tooltip-content',
defaultMessage: 'Failure to enroll by midnight of enrollment deadline date will release funds back into the budget',
defaultMessage: 'Failure to enroll by the enrollment deadline will release funds back into the budget',
description: 'On hover tool tip message for the enroll-by date column',
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/learner-credit-management/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const NO_BALANCE_REMAINING_DOLLAR_THRESHOLD = 100;

export const DATE_FORMAT = 'MMMM DD, YYYY';

export const SHORT_MONTH_DATE_FORMAT = 'MMM DD, YYYY';
export const SHORT_MONTH_DATE_FORMAT = 'MMM D, YYYY';
export const DATETIME_FORMAT = 'MMM D, YYYY h:mma';

export const EXEC_ED_OFFER_TYPE = 'learner_credit';
Expand Down
9 changes: 5 additions & 4 deletions src/components/learner-credit-management/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ export const orderBudgets = (intl, budgets) => {

/**
* Formats a date string to MMM D, YYYY format.
* @param {string} date Date string.
* @returns Formatted date string.
* @param {string} date
* @param {string} format
* @returns {string}
*/
export function formatDate(date) {
return dayjs(date).format('MMM D, YYYY');
export function formatDate(date, format = 'MMM D, YYYY') {
return dayjs(date).format(format);
}

// Exec ed and open courses cards should display either the enrollment deadline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ import EnterpriseAccessApiService from '../../../data/services/EnterpriseAccessA

import BudgetDetailPage from '../BudgetDetailPage';
import {
DEFAULT_PAGE,
formatDate,
formatPrice,
PAGE_SIZE,
useBudgetContentAssignments,
useBudgetDetailActivityOverview,
useBudgetRedemptions,
useEnterpriseCustomer,
useEnterpriseGroup,
useEnterpriseGroupLearners,
useEnterpriseRemovedGroupMembers,
useEnterpriseOffer,
useEnterpriseRemovedGroupMembers,
useIsLargeOrGreater,
useSubsidyAccessPolicy,
useSubsidySummaryAnalyticsApi,
DEFAULT_PAGE,
PAGE_SIZE,
} from '../data';
import { EnterpriseSubsidiesContext } from '../../EnterpriseSubsidiesContext';
import {
Expand Down Expand Up @@ -2573,7 +2573,7 @@ describe('<BudgetDetailPage />', () => {

userEvent.hover(enrollByDateTooltip);
await waitFor(() => expect(screen.getByText(
'Failure to enroll by midnight of enrollment deadline date will release funds back into the budget',
'Failure to enroll by the enrollment deadline will release funds back into the budget',
)).toBeTruthy());
});
});

0 comments on commit 329fae8

Please sign in to comment.