Skip to content

Commit

Permalink
Merge branch 'master' into mashal-m/update_lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Mashal-m authored Sep 11, 2023
2 parents 9b49466 + 4da552c commit 41d656f
Show file tree
Hide file tree
Showing 36 changed files with 1,081 additions and 69 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ FEATURE_SETTINGS_PAGE_LMS_TAB='true'
FEATURE_SETTINGS_PAGE_APPEARANCE_TAB='true'
FEATURE_LEARNER_CREDIT_MANAGEMENT='true'
FEATURE_CONTENT_HIGHLIGHTS='true'
FEATURE_API_CREDENTIALS_TAB='true'
HOTJAR_APP_ID=''
HOTJAR_VERSION='6'
HOTJAR_DEBUG=''
Expand Down
2 changes: 1 addition & 1 deletion src/components/ContactCustomerSupportButton/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ContactCustomerSupportButton.propTypes = {

ContactCustomerSupportButton.defaultProps = {
children: 'Contact support',
variant: 'btn-outline-primary',
variant: 'outline-primary',
};

export default ContactCustomerSupportButton;
11 changes: 4 additions & 7 deletions src/components/forms/FormWorkflow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import type { Dispatch } from 'react';
import {
ActionRow, Button, FullscreenModal, Hyperlink, Stepper, useToggle,
ActionRow, Button, FullscreenModal, Stepper, useToggle,
} from '@edx/paragon';
import { Launch } from '@edx/paragon/icons';

Expand All @@ -14,6 +14,7 @@ import { HELP_CENTER_LINK, SUBMIT_TOAST_MESSAGE } from '../settings/data/constan
import UnsavedChangesModal from '../settings/SettingsLMSTab/UnsavedChangesModal';
import ConfigErrorModal from '../settings/ConfigErrorModal';
import { channelMapping, pollAsync } from '../../utils';
import HelpCenterButton from '../settings/HelpCenterButton';

export const WAITING_FOR_ASYNC_OPERATION = 'WAITING FOR ASYNC OPERATION';

Expand Down Expand Up @@ -201,13 +202,9 @@ const FormWorkflow = <FormConfigData extends unknown>({
className="stepper-modal"
footerNode={(
<ActionRow>
<Hyperlink
destination={helpCenterLink}
className="btn btn-outline-tertiary"
target="_blank"
>
<HelpCenterButton url={helpCenterLink}>
Help Center: Integrations
</Hyperlink>
</HelpCenterButton>
<ActionRow.Spacer />
<Button variant="tertiary" onClick={onCancel}>Cancel</Button>
{nextButtonConfig && (
Expand Down
4 changes: 4 additions & 0 deletions src/components/learner-credit-management/BudgetCard-V2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const BudgetCard = ({
offer,
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => {
const {
start,
Expand Down Expand Up @@ -143,6 +144,8 @@ const BudgetCard = ({
tableData={offerRedemptions}
fetchTableData={fetchOfferRedemptions}
enterpriseUUID={enterpriseUUID}
enterpriseSlug={enterpriseSlug}
enableLearnerPortal={enableLearnerPortal}
/>
)}
</Stack>
Expand All @@ -158,6 +161,7 @@ BudgetCard.propTypes = {
}).isRequired,
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
};

export default BudgetCard;
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';
import dayjs from 'dayjs';
import {
DataTable, useMediaQuery, breakpoints,
} from '@edx/paragon';

import { DataTable, Hyperlink } from '@edx/paragon';
import { getConfig } from '@edx/frontend-platform/config';
import TableTextFilter from './TableTextFilter';
import EmailAddressTableCell from './EmailAddressTableCell';
import { getCourseProductLineText } from '../../utils';

export const PAGE_SIZE = 20;
export const DEFAULT_PAGE = 0; // `DataTable` uses zero-index array

const getEnrollmentDetailsAccessor = row => ({
courseTitle: row.courseTitle,
userEmail: row.userEmail,
courseKey: row.courseKey,
});

const FilterStatus = (rest) => <DataTable.FilterStatus showFilteredFields={false} {...rest} />;

const LearnerCreditAllocationTable = ({
isLoading,
tableData,
fetchTableData,
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => {
const isDesktopTable = useMediaQuery({ minWidth: breakpoints.extraLarge.minWidth });
const defaultFilter = [];

return (
Expand All @@ -29,32 +36,46 @@ const LearnerCreditAllocationTable = ({
manualPagination
isFilterable
manualFilters
showFiltersInSidebar={isDesktopTable}
isLoading={isLoading}
defaultColumnValues={{ Filter: TableTextFilter }}
FilterStatusComponent={FilterStatus}
/* eslint-disable */
columns={[
{
Header: 'Email Address',
accessor: 'userEmail',
// eslint-disable-next-line react/prop-types, react/no-unstable-nested-components
Cell: ({ row }) => <EmailAddressTableCell row={row} enterpriseUUID={enterpriseUUID} />,
Header: 'Date',
accessor: 'enrollmentDate',
Cell: ({ row }) => dayjs(row.values.enrollmentDate).format('MMM D, YYYY'),
disableFilters: true,
},
{
Header: 'Course Name',
accessor: 'courseTitle',
Header: 'Enrollment details',
accessor: getEnrollmentDetailsAccessor,
Cell: ({ row }) => (
<>
<EmailAddressTableCell row={row} enterpriseUUID={enterpriseUUID} />
<div>
{enableLearnerPortal ? (
<Hyperlink
destination={`${getConfig().ENTERPRISE_LEARNER_PORTAL_URL}/${enterpriseSlug}/course/${row.original.courseKey}`}
target="_blank"
>
{row.original.courseTitle}
</Hyperlink>
) : (
row.original.courseTitle
)}
</div>
</>
),
disableFilters: false,
disableSortBy: true,
},
{
Header: 'Course Price',
Header: 'Amount',
accessor: 'courseListPrice',
Cell: ({ row }) => `$${row.values.courseListPrice}`,
disableFilters: true,
},
{
Header: 'Date Spent',
accessor: 'enrollmentDate',
Cell: ({ row }) => dayjs(row.values.enrollmentDate).format('MMMM DD, YYYY'),
disableFilters: true,
},
{
Header: 'Product',
accessor: 'courseProductLine',
Expand All @@ -78,7 +99,6 @@ const LearnerCreditAllocationTable = ({
itemCount={tableData.itemCount}
pageCount={tableData.pageCount}
EmptyTableComponent={
// eslint-disable-next-line react/no-unstable-nested-components
() => {
if (isLoading) {
return null;
Expand All @@ -89,9 +109,12 @@ const LearnerCreditAllocationTable = ({
/>
);
};
/* eslint-enable */

LearnerCreditAllocationTable.propTypes = {
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
isLoading: PropTypes.bool.isRequired,
tableData: PropTypes.shape({
results: PropTypes.arrayOf(PropTypes.shape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const PAGE_TITLE = 'Learner Credit';
const MultipleBudgetsPage = ({
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => {
const { offers, isLoading } = useContext(EnterpriseSubsidiesContext);

Expand Down Expand Up @@ -66,6 +67,7 @@ const MultipleBudgetsPage = ({
offers={offers}
enterpriseUUID={enterpriseUUID}
enterpriseSlug={enterpriseSlug}
enableLearnerPortal={enableLearnerPortal}
/>
</>
);
Expand All @@ -74,11 +76,13 @@ const MultipleBudgetsPage = ({
const mapStateToProps = state => ({
enterpriseUUID: state.portalConfiguration.enterpriseId,
enterpriseSlug: state.portalConfiguration.enterpriseSlug,
enableLearnerPortal: state.portalConfiguration.enableLearnerPortal,
});

MultipleBudgetsPage.propTypes = {
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
};

export default connect(mapStateToProps)(MultipleBudgetsPage);
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const MultipleBudgetsPicker = ({
offers,
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => (
<Stack>
<Row>
Expand All @@ -22,6 +23,7 @@ const MultipleBudgetsPicker = ({
offer={offer}
enterpriseUUID={enterpriseUUID}
enterpriseSlug={enterpriseSlug}
enableLearnerPortal={enableLearnerPortal}
/>
))}
</Col>
Expand All @@ -33,6 +35,7 @@ MultipleBudgetsPicker.propTypes = {
offers: PropTypes.arrayOf(PropTypes.shape()).isRequired,
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
};

export default MultipleBudgetsPicker;
13 changes: 5 additions & 8 deletions src/components/learner-credit-management/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,15 @@ const applySortByToOptions = (sortBy, options) => {
};

const applyFiltersToOptions = (filters, options) => {
const userSearchQuery = filters?.find(filter => filter.id === 'userEmail')?.value;
const courseTitleSearchQuery = filters?.find(filter => filter.id === 'courseTitle')?.value;
const courseProductLineSearchQuery = filters?.find(filter => filter.id === 'courseProductLine')?.value;
if (userSearchQuery) {
Object.assign(options, { search: userSearchQuery });
}
if (courseTitleSearchQuery) {
Object.assign(options, { searchCourse: courseTitleSearchQuery });
}
const searchQuery = filters?.find(filter => filter.id.toLowerCase() === 'enrollment details')?.value;

if (courseProductLineSearchQuery) {
Object.assign(options, { courseProductLine: courseProductLineSearchQuery });
}
if (searchQuery) {
Object.assign(options, { searchAll: searchQuery });
}
};

export const useOfferRedemptions = (enterpriseUUID, offerId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ describe('useOfferRedemptions', () => {
{ id: 'enrollmentDate', desc: true },
],
filters: [
{ id: 'userEmail', value: mockOfferEnrollments[0].user_email },
{ id: 'courseTitle', value: mockOfferEnrollments[0].course_title },
{ id: 'Enrollment Details', value: mockOfferEnrollments[0].user_email },
],
});
});
Expand All @@ -118,8 +117,7 @@ describe('useOfferRedemptions', () => {
pageSize: 20,
offerId: mockEnterpriseOffer.id,
ordering: '-enrollment_date', // default sort order
search: mockOfferEnrollments[0].user_email,
searchCourse: mockOfferEnrollments[0].course_title,
searchAll: mockOfferEnrollments[0].user_email,
ignoreNullCourseListPrice: true,
};
expect(EnterpriseDataApiService.fetchCourseEnrollments).toHaveBeenCalledWith(
Expand Down
1 change: 1 addition & 0 deletions src/components/learner-credit-management/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const transformUtilizationTableResults = results => results.map(result =>
enrollmentDate: result.enrollmentDate,
courseProductLine: result.courseProductLine,
uuid: uuidv4(),
courseKey: result.courseKey,
}));

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ describe('<BudgetCard />', () => {
const elementsWithTestId = screen.getAllByTestId('view-budget');
const firstElementWithTestId = elementsWithTestId[0];
await waitFor(() => userEvent.click(firstElementWithTestId));
expect(screen.getByText('Filters'));
expect(screen.getByText('No results found'));
});
});
Expand Down
Loading

0 comments on commit 41d656f

Please sign in to comment.