Skip to content

Commit

Permalink
UIU-2964 - Disable open loan actions for virtual patron
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed Nov 13, 2023
1 parent 0de90a1 commit 03ad456
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 215 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [10.1.0] IN PROGRESS

* Also support `feesfines` interface version `19.0`. Refs UIU-2960.
* Disable open loan actions for virtual patron. Refs UIU-2964.

## [10.0.4](https://github.com/folio-org/ui-users/tree/v10.0.4) (2023-11-10)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v10.0.3...v10.0.4)
Expand Down
4 changes: 4 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,7 @@ export const USER_TYPES = {
SYSTEM: 'system',
DCB: 'dcb',
};

export const DCB_USER = {
lastName: 'DcbSystem'
};
35 changes: 20 additions & 15 deletions src/views/LoanDetails/LoanDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
accountsMatchStatus,
checkUserActive,
} from '../../components/util';
import { itemStatuses, loanActions, refundClaimReturned } from '../../constants';
import { itemStatuses, loanActions, refundClaimReturned, DCB_USER } from '../../constants';
import {
withRenew,
withDeclareLost,
Expand Down Expand Up @@ -487,6 +487,7 @@ class LoanDetails extends React.Component {
const patronBlocksForModal = getRenewalPatronBlocksFromPatronBlocks(patronBlocks);
const isUserActive = user ? checkUserActive(user) : false;
const borrower = user ? getFullName(user) : <FormattedMessage id="ui-users.user.unknown" />;
const isVirtualPatron = user?.personal?.lastName === DCB_USER.lastName;

return (
<div data-test-loan-actions-history>
Expand All @@ -507,7 +508,7 @@ class LoanDetails extends React.Component {
<IfPermission perm="ui-users.loans.renew">
<Button
data-test-renew-button
disabled={buttonDisabled || isClaimedReturnedItem || !isUserActive}
disabled={buttonDisabled || isClaimedReturnedItem || !isUserActive || isVirtualPatron}
buttonStyle="primary"
onClick={this.renew}
>
Expand All @@ -525,7 +526,7 @@ class LoanDetails extends React.Component {
<Button
buttonStyle="dropdownItem"
data-test-declare-lost-button
disabled={buttonDisabled || isDeclaredLostItem}
disabled={buttonDisabled || isDeclaredLostItem || isVirtualPatron}
onClick={() => declareLost(loan, itemRequestCount)}
>
<FormattedMessage id="ui-users.loans.declareLost" />
Expand All @@ -535,6 +536,7 @@ class LoanDetails extends React.Component {
<Button
buttonStyle="dropdownItem"
data-test-dropdown-content-mark-as-missing-button
disabled={isVirtualPatron}
onClick={() => markAsMissing(loan, itemRequestCount)}
>
<FormattedMessage id="ui-users.loans.markAsMissing" />
Expand All @@ -544,16 +546,16 @@ class LoanDetails extends React.Component {
</Dropdown>
}
{!isClaimedReturnedItem &&
<IfPermission perm="ui-users.loans.claim-item-returned">
<Button
data-test-claim-returned-button
disabled={buttonDisabled}
buttonStyle="primary"
onClick={() => claimReturned(loan, itemRequestCount)}
>
<FormattedMessage id="ui-users.loans.claimReturned" />
</Button>
</IfPermission>
<IfPermission perm="ui-users.loans.claim-item-returned">
<Button
data-test-claim-returned-button
disabled={buttonDisabled || isVirtualPatron}
buttonStyle="primary"
onClick={() => claimReturned(loan, itemRequestCount)}
>
<FormattedMessage id="ui-users.loans.claimReturned" />
</Button>
</IfPermission>
}
<IfPermission perm="ui-users.loans.change-due-date">
<Button
Expand All @@ -562,7 +564,8 @@ class LoanDetails extends React.Component {
buttonDisabled ||
isDeclaredLostItem ||
isClaimedReturnedItem ||
isAgedToLostItem
isAgedToLostItem ||
isVirtualPatron
}
buttonStyle="primary"
onClick={this.showChangeDueDateDialog}
Expand All @@ -573,7 +576,7 @@ class LoanDetails extends React.Component {
<IfPermission perm="ui-users.loans.declare-item-lost">
<Button
data-test-declare-lost-button
disabled={declareLostInProgress || buttonDisabled || isDeclaredLostItem}
disabled={declareLostInProgress || buttonDisabled || isDeclaredLostItem || isVirtualPatron}
buttonStyle="primary"
onClick={() => declareLost(loan, itemRequestCount)}
>
Expand All @@ -583,6 +586,7 @@ class LoanDetails extends React.Component {
<IfPermission perm="ui-users.loans.add-patron-info">
<Button
data-test-new-patron-info-button
disabled={isVirtualPatron}
onClick={() => addInfo(loan, 'patron')}
>
<FormattedMessage id="ui-users.loans.newPatronInfo" />
Expand All @@ -591,6 +595,7 @@ class LoanDetails extends React.Component {
<IfPermission perm="ui-users.loans.add-staff-info">
<Button
data-test-new-staff-info-button
disabled={isVirtualPatron}
onClick={() => addInfo(loan, 'staff')}
>
<FormattedMessage id="ui-users.loans.newStaffInfo" />
Expand Down
Loading

0 comments on commit 03ad456

Please sign in to comment.