Skip to content
Draft
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
71 changes: 51 additions & 20 deletions src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
GROUP_MEMBERS_TABLE_PAGE_SIZE, GROUP_MEMBERS_TABLE_DEFAULT_PAGE,
} from './constants';
import MemberDetailsCell from './MemberDetailsCell';
import AddMembersBulkAction from './GroupDetailPage/AddMembersBulkAction';

Check failure on line 15 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

'AddMembersBulkAction' is defined but never used
import RemoveMembersBulkAction from './RemoveMembersBulkAction';

Check failure on line 16 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

'RemoveMembersBulkAction' is defined but never used
import MemberJoinedDateCell from './MemberJoinedDateCell';
import { useEnterpriseMembersTableData } from './data/hooks';
import { useGetAllEnterpriseLearnerEmails } from './data/hooks/useEnterpriseLearnersTableData';
import { getSelectedEmailsByRow } from './utils';

export const BaseSelectWithContext = ({ row, enterpriseGroupLearners }) => {
const {
Expand Down Expand Up @@ -59,20 +61,41 @@
type: 'DELETE ROW', rowId,
});

const CustomSelectColumnCell = ({ row }) => {
const CustomSelectColumnCell = ({row, isEntireTableSelected, selectedFlatRows, onHandleAddMembersBulkAction, enterpriseId}) => {

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

This line has a length of 128. Maximum allowed is 120

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

A space is required after '{'

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

Expected a line break after this opening brace

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

'isEntireTableSelected' is missing in props validation

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

'selectedFlatRows' is missing in props validation

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

'onHandleAddMembersBulkAction' is missing in props validation

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

'enterpriseId' is missing in props validation

Check failure on line 64 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

A space is required before '}'
const { enterpriseGroupLearners } = useContext(EnterpriseCustomerUserDataTableContext);
const [isAddedMember, setIsAddedMember] = useState(false);
const {
itemCount,
controlledTableSelections: [, dispatch],
} = useContext(DataTableContext);

const { fetchLearnerEmails, addButtonState } = useGetAllEnterpriseLearnerEmails({
enterpriseId,
isEntireTableSelected,
onHandleAddMembersBulkAction,
enterpriseGroupLearners,
});
const handleOnClick = () => {
console.log(isEntireTableSelected)

Check warning on line 79 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement
if (isEntireTableSelected) {
fetchLearnerEmails();
return;
}
const addedMemberEmails = enterpriseGroupLearners.map(learner => learner.memberDetails.userEmail);
console.log(selectedFlatRows)

Check warning on line 85 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement
const emails = getSelectedEmailsByRow(selectedFlatRows).filter(email => !addedMemberEmails.includes(email));
onHandleAddMembersBulkAction(emails);
};

const toggleSelected = useCallback(
() => {
if (row.isSelected) {
console.log('hello')

Check warning on line 93 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement
dispatch(deleteSelectedRowAction(row.id));
} else {
console.log('adding cell')

Check warning on line 96 in src/components/PeopleManagement/EnterpriseCustomerUserDataTable.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement
dispatch(addSelectedRowAction(row, itemCount));
handleOnClick()
}
},
[itemCount, row, dispatch],
Expand Down Expand Up @@ -123,12 +146,12 @@
fetchEnterpriseMembersTableData,
} = useEnterpriseMembersTableData({ enterpriseId });

const selectColumn = {
id: 'selection',
Header: DataTable.ControlledSelectHeader,
Cell: CustomSelectColumnCell,
disableSortBy: true,
};
// const selectColumn = {
// id: 'selection',
// Header: DataTable.ControlledSelectHeader,
// Cell: CustomSelectColumnCell,
// disableSortBy: true,
// };

const contextValue = useMemo(() => ({
enterpriseGroupLearners,
Expand All @@ -137,18 +160,18 @@
return (
<EnterpriseCustomerUserDataTableContext.Provider value={contextValue}>
<DataTable
bulkActions={[
<AddMembersBulkAction
onHandleAddMembersBulkAction={onHandleAddMembersBulkAction}
enterpriseId={enterpriseId}
enterpriseGroupLearners={enterpriseGroupLearners}
/>,
<RemoveMembersBulkAction
enterpriseId={enterpriseId}
learnerEmails={learnerEmails}
onHandleRemoveMembersBulkAction={onHandleRemoveMembersBulkAction}
/>,
]}
// bulkActions={[
// <AddMembersBulkAction
// onHandleAddMembersBulkAction={onHandleAddMembersBulkAction}
// enterpriseId={enterpriseId}
// enterpriseGroupLearners={enterpriseGroupLearners}
// />,
// <RemoveMembersBulkAction
// enterpriseId={enterpriseId}
// learnerEmails={learnerEmails}
// onHandleRemoveMembersBulkAction={onHandleRemoveMembersBulkAction}
// />,
// ]}
columns={[
{
Header: 'Member details',
Expand Down Expand Up @@ -187,7 +210,15 @@
getRowId: row => row.enterpriseCustomerUser.userId.toString(),
}}
pageCount={enterpriseMembersTableData.pageCount}
manualSelectColumn={selectColumn}
manualSelectColumn={
{
id: 'selection',
Header: DataTable.ControlledSelectHeader,
/* eslint-disable react/no-unstable-nested-components */
Cell: (row) => <CustomSelectColumnCell enterpriseId={enterpriseId} onHandleAddMembersBulkAction={onHandleAddMembersBulkAction} {...row} />,
disableSortBy: true,
}
}
SelectionStatusComponent={DataTable.ControlledSelectionStatus}
/>
</EnterpriseCustomerUserDataTableContext.Provider>
Expand Down
Loading