Skip to content

Commit

Permalink
Merge branch 'master' into UIU-2988
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka authored Nov 27, 2023
2 parents 6a4aabb + ab63bab commit 6502f16
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 36 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Also support `feesfines` interface version `19.0`. Refs UIU-2960.
* Disable validation for shadow user. Refs UIU-3000.
* Disable open loan actions for virtual patron. Refs UIU-2964.
* Fix problem with Date field in User app reports does not populate when a first entry was cleared. Refs UIU-2991.
* Hide all actionalble buttons on user details pane for DCB Virtual user. Refs UIU-2987.
* Open loan page modifications for a virtual patron. Refs UIU-2988.

## [10.0.4](https://github.com/folio-org/ui-users/tree/v10.0.4) (2023-11-10)
Expand Down
7 changes: 3 additions & 4 deletions src/components/ReportModals/CashDrawerReportModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@folio/stripes/components';

import { DATE_FORMAT } from '../../constants';

import css from './ReportModal.css';

export const validate = (options) => {
Expand Down Expand Up @@ -57,7 +58,6 @@ const CashDrawerReportModal = (props) => {
cashDrawerReportSources,
} = props;
const [sources, setSources] = useState([]);
const parseDate = (date) => (date ? moment.tz(date, props.timezone).format(DATE_FORMAT) : date);
const servicePoints = props.servicePoints.map(({ id, name }) => ({
value: id,
label: name,
Expand Down Expand Up @@ -119,16 +119,16 @@ const CashDrawerReportModal = (props) => {
name="startDate"
required
component={Datepicker}
backendDateStandard={DATE_FORMAT}
autoFocus
parse={parseDate}
/>
</Col>
<Col xs={6}>
<Field
label={<FormattedMessage id="ui-users.reports.refunds.modal.endDate" />}
name="endDate"
component={Datepicker}
parse={parseDate}
backendDateStandard={DATE_FORMAT}
/>
</Col>
<Col xs={12}>
Expand Down Expand Up @@ -189,7 +189,6 @@ CashDrawerReportModal.propTypes = {
servicePoints: PropTypes.arrayOf(PropTypes.object).isRequired,
onClose: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
timezone: PropTypes.string.isRequired,
values: PropTypes.object.isRequired,
cashDrawerReportSources: PropTypes.shape({
POST: PropTypes.func.isRequired,
Expand Down
1 change: 0 additions & 1 deletion src/components/ReportModals/CashDrawerReportModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const renderCashDrawerReportModal = ({
open
label={label}
servicePoints={servicePoints}
timezone="America/New_York"
onClose={onClose}
onSubmit={handleSubmit}
initialValues={initialValues}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@folio/stripes/components';

import { DATE_FORMAT } from '../../constants';

import css from './ReportModal.css';

export const validate = (options) => {
Expand Down Expand Up @@ -52,7 +53,6 @@ const FinancialTransactionsReportModal = (props) => {
values: { feeFineOwner: ownerValue = '' },
owners,
} = props;
const parseDate = (date) => (date ? moment.tz(date, props.timezone).format(DATE_FORMAT) : date);
const formattedOwners = owners.map(({ id, owner }) => ({
value: id,
label: owner,
Expand Down Expand Up @@ -112,16 +112,16 @@ const FinancialTransactionsReportModal = (props) => {
name="startDate"
required
component={Datepicker}
backendDateStandard={DATE_FORMAT}
autoFocus
parse={parseDate}
/>
</Col>
<Col xs={6}>
<Field
label={<FormattedMessage id="ui-users.reports.refunds.modal.endDate" />}
name="endDate"
component={Datepicker}
parse={parseDate}
backendDateStandard={DATE_FORMAT}
/>
</Col>
<Col xs={12}>
Expand Down Expand Up @@ -160,7 +160,6 @@ FinancialTransactionsReportModal.propTypes = {
owners: PropTypes.arrayOf(PropTypes.object).isRequired,
onClose: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
timezone: PropTypes.string.isRequired,
values: PropTypes.object.isRequired,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const renderFinancialTransactionsReportModal = ({
open
label={label}
servicePoints={servicePoints}
timezone="America/New_York"
onClose={onClose}
onSubmit={handleSubmit}
values={values}
Expand Down
9 changes: 4 additions & 5 deletions src/components/ReportModals/RefundsReportModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
MultiSelection,
} from '@folio/stripes/components';

import { DATE_FORMAT } from '../../constants';

import css from './ReportModal.css';

const validate = ({ startDate, endDate }) => {
Expand All @@ -42,8 +44,6 @@ const RefundsReportModal = (props) => {
valid,
} = props.form.getState();

const parseDate = (date) => (date ? moment.tz(date, props.timezone).format('YYYY-MM-DD') : date);

const feeFineOwners = props.owners.map(({ id, owner }) => ({
value: id,
label: owner,
Expand Down Expand Up @@ -97,8 +97,8 @@ const RefundsReportModal = (props) => {
label={<FormattedMessage id="ui-users.reports.refunds.modal.startDate" />}
name="startDate"
component={Datepicker}
backendDateStandard={DATE_FORMAT}
autoFocus
parse={parseDate}
/>
</Col>
<Col
Expand All @@ -109,7 +109,7 @@ const RefundsReportModal = (props) => {
label={<FormattedMessage id="ui-users.reports.refunds.modal.endDate" />}
name="endDate"
component={Datepicker}
parse={parseDate}
backendDateStandard={DATE_FORMAT}
/>
</Col>
<Col
Expand Down Expand Up @@ -137,7 +137,6 @@ RefundsReportModal.propTypes = {
owners: PropTypes.arrayOf(PropTypes.object).isRequired,
onClose: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
timezone: PropTypes.string.isRequired,
};

export default stripesFinalForm({
Expand Down
1 change: 0 additions & 1 deletion src/components/ReportModals/RefundsReportModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const propData = {
label: 'TestLabelRefundsModal',
intl: { formatMessage : jest.fn() },
handleSubmit: jest.fn(),
timezone: 'America/New_York',
onSubmit: jest.fn(),
};

Expand Down
12 changes: 11 additions & 1 deletion src/components/UserDetailSections/PatronBlock/PatronBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '@folio/stripes/components';
import { stripesConnect } from '@folio/stripes/core';

import { isDcbUser } from '../../util';
import css from './PatronBlock.css';

const PATRON_BLOCKS_COLUMNS = {
Expand All @@ -37,6 +38,11 @@ class PatronBlock extends React.Component {
expanded: PropTypes.bool,
accordionId: PropTypes.string,
patronBlocks: PropTypes.arrayOf(PropTypes.object),
resources: PropTypes.shape({
selUser: PropTypes.shape({
records: PropTypes.arrayOf(PropTypes.object),
}),
}),
mutator: PropTypes.shape({
activeRecord: PropTypes.shape({
update: PropTypes.func,
Expand Down Expand Up @@ -160,7 +166,11 @@ class PatronBlock extends React.Component {
patronBlocks,
match: { params },
location,
resources,
} = this.props;

const user = resources?.selUser?.records[0];

const {
sortOrder,
sortDirection,
Expand Down Expand Up @@ -203,7 +213,7 @@ class PatronBlock extends React.Component {
id={accordionId}
onToggle={onToggle}
label={title}
displayWhenOpen={displayWhenOpen}
displayWhenOpen={!isDcbUser(user) ? displayWhenOpen : null}
>
<Row><Col xs>{items}</Col></Row>
</Accordion>
Expand Down
39 changes: 28 additions & 11 deletions src/components/UserDetailSections/PatronBlock/PatronBlock.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen } from '@folio/jest-config-stripes/testing-library/react';
import { act, screen } from '@folio/jest-config-stripes/testing-library/react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';

import renderWithRouter from 'helpers/renderWithRouter';
Expand Down Expand Up @@ -52,20 +52,37 @@ const props = {
};

describe('render ProxyPermissions component', () => {
beforeEach(() => {
renderPatronBlock(props);
});
it('Component must be rendered', () => {
renderPatronBlock(props);
expect(screen.getByText('ui-users.settings.patronBlocks')).toBeInTheDocument();
});
it('Clicking the patron row should redirect via history.push', async () => {
await userEvent.click(document.querySelector('[data-row-inner="0"]'));
renderPatronBlock(props);
await act(async () => userEvent.click(document.querySelector('[data-row-inner="0"]')));
expect(mockRedirect).toHaveBeenCalled();
});
/* Need to fix the bug UIU-2538 for the sorting to work so that this test case can be uncommented */

// it('checking for sort order', () => {
// userEvent.click(document.querySelector('[id="clickable-list-column-blockedactions"]'));
// expect(screen.getByText('Sample')).toBeInTheDocument();
// });
it('checking for sort order', () => {
renderPatronBlock(props);
userEvent.click(document.querySelector('[id="clickable-list-column-blockedactions"]'));
expect(screen.getByText('Sample')).toBeInTheDocument();
});
describe('when user is of type "dcb"', () => {
it('should not display "Create block" button', () => {
const alteredProps = {
...props,
resources: {
selUser: {
records: [
{
personal: { lastName: 'DcbSystem' },
type: 'dcb'
}
]
}
}
};
renderPatronBlock(alteredProps);
expect(screen.queryByText('Create block')).toBeNull();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { FormattedMessage } from 'react-intl';
import { get } from 'lodash';

import {
Row,
Expand All @@ -20,6 +21,7 @@ import {
refundStatuses,
refundClaimReturned,
} from '../../../constants';
import { isDcbUser } from '../../util';


/**
Expand All @@ -39,6 +41,7 @@ const UserAccounts = ({
},
resources,
}) => {
const user = get(resources, ['selUser', 'records', '0']);
const [totals, setTotals] = useState({
openAccountsCount: 0,
closedAccountsCount: 0,
Expand Down Expand Up @@ -98,7 +101,7 @@ const UserAccounts = ({
onToggle={onToggle}
label={<Headline size="large" tag="h3"><FormattedMessage id="ui-users.accounts.title.feeFine" /></Headline>}
displayWhenClosed={displayWhenClosed}
displayWhenOpen={displayWhenOpen}
displayWhenOpen={!isDcbUser(user) ? displayWhenOpen : null}
>
{accountsLoaded ?
<Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,39 @@ describe('Render UserAccounts component', () => {
renderUserAccounts(props(false));
expect(document.querySelector('[id="numOpenAccounts"]')).toBeNull();
});
describe('when user is of type dcb', () => {
it('should not display "Create fee/fine" button', () => {
const alteredProps = {
accounts : {
records: [accounts],
isPending: false,
},
accordionId: 'UserAccounts',
expanded: true,
onToggle: onToggleMock,
location: {
search: '',
path: '/userAccounts'
},
match: {
params: {
id: ''
}
},
resources: {
...resources,
selUser: {
records: [
{
personal: { lastName: 'DcbSystem' },
type: 'dcb'
}
]
},
},
};
renderUserAccounts(alteredProps);
expect(screen.queryByText('Create fee/fine')).toBeNull();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
getOpenRequestStatusesFilterString,
getClosedRequestStatusesFilterString,
getRequestUrl,
isDcbUser,
} from '../../util';

/**
Expand Down Expand Up @@ -107,12 +108,10 @@ class UserRequests extends React.Component {
expanded,
onToggle,
accordionId,
user: {
barcode,
id,
},
user,
resources
} = this.props;
const { barcode, id } = user;
const openRequestsTotal = _.get(resources.openRequestsCount, ['records', '0', 'totalRecords'], 0);
const closedRequestsTotal = _.get(resources.closedRequestsCount, ['records', '0', 'totalRecords'], 0);
const openRequestsCount = (_.get(resources.openRequestsCount, ['isPending'], true)) ? -1 : openRequestsTotal;
Expand Down Expand Up @@ -142,7 +141,7 @@ class UserRequests extends React.Component {
onToggle={onToggle}
label={<Headline size="large" tag="h3"><FormattedMessage id="ui-users.requests.title" /></Headline>}
displayWhenClosed={displayWhenClosed}
displayWhenOpen={displayWhenOpen}
displayWhenOpen={!isDcbUser(user) ? displayWhenOpen : null}
>
{requestsLoaded ?
<List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,20 @@ describe('Render User Requests component', () => {
renderUserRequests(props(false));
expect(screen.getByText('List Component')).toBeInTheDocument();
});

describe('when user is of type dcb', () => {
it('should not display "Create Request" button', () => {
const alteredProps = (perm) => {
return {
...props(perm),
user: {
personal: { lastName: 'DcbSystem' },
type: 'dcb'
},
};
};
renderUserRequests(alteredProps(true));
expect(screen.queryByText('Create Request')).toBeNull();
});
});
});
Loading

0 comments on commit 6502f16

Please sign in to comment.