Skip to content

Commit

Permalink
chore: add product column
Browse files Browse the repository at this point in the history
  • Loading branch information
emrosarioa committed Aug 30, 2023
1 parent c28551e commit b7bc888
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import dayjs from 'dayjs';
import {
Avatar, DataTable, Hyperlink, 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 getDescriptionAccessor = row => ({
const getEnrollmentDetailsAccessor = row => ({
courseTitle: row.courseTitle,
userEmail: row.userEmail,
courseKey: row.courseKey,
Expand All @@ -24,7 +23,6 @@ const LearnerCreditAllocationTable = ({
enterpriseUUID,
enterpriseSlug,
}) => {
const isDesktopTable = useMediaQuery({ minWidth: breakpoints.extraLarge.minWidth });
const defaultFilter = [];

return (
Expand All @@ -35,7 +33,6 @@ const LearnerCreditAllocationTable = ({
manualPagination
isFilterable
manualFilters
showFiltersInSidebar={isDesktopTable}
isLoading={isLoading}
defaultColumnValues={{ Filter: TableTextFilter }}
/* eslint-disable */
Expand All @@ -47,19 +44,16 @@ const LearnerCreditAllocationTable = ({
disableFilters: true,
},
{
Header: 'Description',
accessor: getDescriptionAccessor,
Header: 'Enrollment Details',
accessor: getEnrollmentDetailsAccessor,
Cell: ({ row }) => (
<>
<Avatar size="xs" />{' '}
<EmailAddressTableCell row={row} enterpriseUUID={enterpriseUUID} />
<div>
<Hyperlink
// eslint-disable-next-line react/prop-types
destination={`${getConfig().ENTERPRISE_LEARNER_PORTAL_URL}/${enterpriseSlug}/course/${row.original.courseKey}`}
target="_blank"
>
{/* eslint-disable-next-line react/prop-types */}
{row.original.courseTitle}
</Hyperlink>
</div>
Expand All @@ -74,6 +68,12 @@ const LearnerCreditAllocationTable = ({
Cell: ({ row }) => `$${row.values.courseListPrice}`,
disableFilters: true,
},
{
Header: 'Product',
accessor: 'courseProductLine',
Cell: ({ row }) => getCourseProductLineText(row.values.courseProductLine),
disableFilters: true,
},
]}
initialTableOptions={{
getRowId: row => row?.uuid?.toString(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/learner-credit-management/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const applySortByToOptions = (sortBy, options) => {

const applyFiltersToOptions = (filters, options) => {
const courseProductLineSearchQuery = filters?.find(filter => filter.id === 'courseProductLine')?.value;
const searchQuery = filters?.find(filter => filter.id.toLowerCase() === 'description')?.value;
const searchQuery = filters?.find(filter => filter.id.toLowerCase() === 'enrollment details')?.value;

if (courseProductLineSearchQuery) {
Object.assign(options, { courseProductLine: courseProductLineSearchQuery });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('useOfferRedemptions', () => {
{ id: 'enrollmentDate', desc: true },
],
filters: [
{ id: 'Description', value: mockOfferEnrollments[0].user_email },
{ id: 'Enrollment Details', value: mockOfferEnrollments[0].user_email },
],
});
});
Expand Down

0 comments on commit b7bc888

Please sign in to comment.