Skip to content
Open
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
21 changes: 8 additions & 13 deletions src/components/UserManagement/ActiveCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ function ActiveCell(props) {
const now = moment();

function deriveUserStatus({ isActive, reactivationDate, endDate }) {
if (reactivationDate) return UserStatus.Paused;


if (isActive === false) return UserStatus.Inactive;


if (isActive && !!endDate && moment(endDate).isAfter(now)) return UserStatus.Scheduled;

if (endDate) return UserStatus.Inactive;
if (isActive) return UserStatus.Active;

return UserStatus.Inactive;
}
if (reactivationDate) return UserStatus.Paused;

if (!isActive) return UserStatus.Inactive;

if (!!endDate && moment(endDate).isAfter(now)) return UserStatus.Scheduled;

return UserStatus.Active;
}

const isScheduled = deriveUserStatus({ isActive, reactivationDate, endDate }) === UserStatus.Scheduled;
const isPaused = deriveUserStatus({ isActive, reactivationDate, endDate }) === UserStatus.Paused;
Expand Down
14 changes: 7 additions & 7 deletions src/components/UserManagement/UserManagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ import SetUpFinalDayPopUp from './SetUpFinalDayPopUp';
import LogTimeOffPopUp from './logTimeOffPopUp';
import SetupNewUserPopup from './setupNewUserPopup';
import { getAllTimeOffRequests } from '../../actions/timeOffRequestAction';
import {
scheduleDeactivationAction,
deactivateImmediatelyAction,
} from '../../actions/userLifecycleActions';
import { scheduleDeactivationAction, activateUserAction, deactivateImmediatelyAction } from '../../actions/userLifecycleActions';

class UserManagement extends React.PureComponent {
filteredUserDataCount = 0;
Expand Down Expand Up @@ -420,9 +417,12 @@ class UserManagement extends React.PureComponent {
};

reactivateUser = async (user = this.state.selectedUser) => {
await this.props.dispatch(updateUserPauseStatus(user, UserStatus.Active, Date.now()));
await this.props.getAllUserProfile();
};
await activateUserAction(
this.props.dispatch,
user,
this.props.getAllUserProfile,
);
};

onUserUpdate = (updatedUser) => {
const { userProfiles } = this.props.state.allUserProfiles;
Expand Down
13 changes: 2 additions & 11 deletions src/components/UserManagement/__tests__/UserManagement.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ import { fireEvent, render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { Provider } from 'react-redux';

import { updateUserPauseStatus } from '../../../actions/userManagement';

vi.mock('../../../actions/userManagement', async () => {
const actual = await vi.importActual('../../../actions/userManagement');
return {
...actual,
updateUserPauseStatus: vi.fn(() => async () => undefined),
};
});

const createThunkStore = () => ({
getState: () => ({
Expand Down Expand Up @@ -79,10 +70,10 @@ describe('UserManagement Component', () => {
expect(screen.getByTestId('user-management-table')).toBeInTheDocument();
});

it('calls updateUserPauseStatus when resuming user', () => {
it('calls activateUserAction when resuming user', () => {
renderUserManagement(<UserManagement {...props} />);
fireEvent.click(screen.getByTestId('pause-resume-button-0'));
expect(updateUserPauseStatus).toHaveBeenCalled();
expect(props.getAllUserProfile).toHaveBeenCalled();
});

it('handles final day action when clicked', () => {
Expand Down
Loading