Skip to content

Commit

Permalink
UIU-2964 - Disable open loan actions for virtual patron (#2588)
Browse files Browse the repository at this point in the history
* UIU-2964 - Disable open loan actions for virtual patron

* UIU-2964 - refine and fix lint issues

* UIU-2964 - refine and clean
  • Loading branch information
Terala-Priyanka authored Nov 20, 2023
1 parent 616a9b6 commit 705b58e
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 214 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* 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.

## [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
34 changes: 20 additions & 14 deletions src/views/LoanDetails/LoanDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
getRenewalPatronBlocksFromPatronBlocks,
accountsMatchStatus,
checkUserActive,
isDcbUser,
} from '../../components/util';
import { itemStatuses, loanActions, refundClaimReturned } from '../../constants';
import {
Expand Down Expand Up @@ -487,6 +488,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 = isDcbUser(user);

return (
<div data-test-loan-actions-history>
Expand All @@ -507,7 +509,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 +527,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 +537,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 +547,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 +565,8 @@ class LoanDetails extends React.Component {
buttonDisabled ||
isDeclaredLostItem ||
isClaimedReturnedItem ||
isAgedToLostItem
isAgedToLostItem ||
isVirtualPatron
}
buttonStyle="primary"
onClick={this.showChangeDueDateDialog}
Expand All @@ -573,7 +577,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 +587,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 +596,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 705b58e

Please sign in to comment.