From 866fe8acd2c735ed77abe95f94e4a63ac6d93d9c Mon Sep 17 00:00:00 2001 From: Priyanka Date: Thu, 30 Nov 2023 21:04:41 +0530 Subject: [PATCH 1/3] UICHKIN-403 - refinement --- CHANGELOG.md | 1 + src/CheckIn.js | 2 + .../FeeFineDetailsButton.test.js | 4 +- src/consts.js | 11 ++++- src/util.js | 8 +++- src/util.test.js | 40 +++++++++++++++++-- 6 files changed, 58 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7414ef3..b823914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 9.1.0 IN PROGRESS * Also support `feesfines` interface version `19.0`. Refs UICHKIN-401. * Hide fee/fine action menu items when requester is virtual user. Refs UICHKIN-398. +* Hide “Item details” option in Actions menu when item is virtual. Refs UICHKIN-403. ## [9.0.1] (https://github.com/folio-org/ui-checkin/tree/v9.0.1) (2023-10-23) [Full Changelog](https://github.com/folio-org/ui-checkin/compare/v9.0.0...v9.0.1) diff --git a/src/CheckIn.js b/src/CheckIn.js index d84baad..99e7c80 100644 --- a/src/CheckIn.js +++ b/src/CheckIn.js @@ -40,6 +40,7 @@ import { convertToSlipData, getCheckinSettings, isDcbUser, + isDCBItem, } from './util'; import styles from './checkin.css'; @@ -305,6 +306,7 @@ class CheckIn extends React.Component { locale, }, } = this.props; + console.log('props ', this.props); const isCheckInNote = element => element.noteType === 'Check in'; const checkinNotePresent = get(loan.item, ['circulationNotes'], []).some(isCheckInNote); diff --git a/src/components/FeeFineDetailsButton/FeeFineDetailsButton.test.js b/src/components/FeeFineDetailsButton/FeeFineDetailsButton.test.js index 73e37d2..dd60f14 100644 --- a/src/components/FeeFineDetailsButton/FeeFineDetailsButton.test.js +++ b/src/components/FeeFineDetailsButton/FeeFineDetailsButton.test.js @@ -9,7 +9,7 @@ import { import { account as accountFixture } from '../../../test/jest/fixtures/account'; import { loan as loanFixture } from '../../../test/jest/fixtures/loan'; import FeeFineDetailsButton from './FeeFineDetailsButton'; -import { DCB_USER } from '../../consts'; +import { DCB_USER_LASTNAME } from '../../consts'; const mockedQueryUpdate = jest.fn(); const labelIds = { @@ -203,7 +203,7 @@ describe('FeeFineDetailsButton', () => { ...loanFixture.loan, borrower: { ...loanFixture.loan.borrower, - lastName: DCB_USER.lastName, + lastName: DCB_USER_LASTNAME, } } }; diff --git a/src/consts.js b/src/consts.js index 1938bbd..9661ad4 100644 --- a/src/consts.js +++ b/src/consts.js @@ -57,6 +57,15 @@ export const cancelFeeClaimReturned = { export const MAX_RECORDS = '1000'; +export const DCB_USER_LASTNAME = 'DcbSystem'; +export const DCB = 'dcb'; + export const DCB_USER = { - lastName: 'DcbSystem', + personal: { + lastName: DCB_USER_LASTNAME, + }, + type: DCB, }; + +export const DCB_INSTANCE_ID = '9d1b77e4-f02e-4b7f-b296-3f2042ddac54'; +export const DCB_HOLDINGS_RECORD_ID = '10cd3a5a-d36f-4c7a-bc4f-e1ae3cf820c9'; diff --git a/src/util.js b/src/util.js index 924e561..3deef04 100644 --- a/src/util.js +++ b/src/util.js @@ -5,8 +5,10 @@ import { } from 'lodash'; import { - DCB_USER, + DCB_USER_LASTNAME, statuses, + DCB_INSTANCE_ID, + DCB_HOLDINGS_RECORD_ID, } from './consts'; export const escapeValue = (val) => { @@ -167,6 +169,8 @@ export function shouldConfirmStatusModalBeShown(item) { ], item?.status?.name); } -export const isDcbUser = (user) => user?.lastName === DCB_USER.lastName; +export const isDcbUser = (user) => user?.personal?.lastName === DCB_USER_LASTNAME && user.type === 'dcb'; + +export const isDCBItem = (item) => item.instanceId === DCB_INSTANCE_ID && item.holdingsRecordId === DCB_HOLDINGS_RECORD_ID; export default {}; diff --git a/src/util.test.js b/src/util.test.js index f97f3a1..b42851a 100644 --- a/src/util.test.js +++ b/src/util.test.js @@ -17,6 +17,8 @@ import { import { DCB_USER, + DCB_INSTANCE_ID, + DCB_HOLDINGS_RECORD_ID, statuses, } from './consts'; @@ -323,9 +325,7 @@ describe('shouldConfirmStatusModalBeShown', () => { describe('isDcbUser', () => { it('should return true when user has lastName as "DcbSystem"', () => { - const user = { - lastName: DCB_USER.lastName, - }; + const user = DCB_USER; expect(isDcbUser(user)).toBeTruthy(); }); @@ -338,3 +338,37 @@ describe('isDcbUser', () => { expect(isDcbUser(user)).toBeFalsy(); }); }); + +describe('isDCBItem ', () => { + it('should return true when both item instance id and item holdings record id are DCB_INSTANCE_ID and DCB_HOLDINGS_RECORD_ID respectively', () => { + const item = { + instanceId: DCB_INSTANCE_ID, + holdingsRecordId: DCB_HOLDINGS_RECORD_ID, + }; + expect(isDCBItem(item)).toBeTruthy(); + }); + + it('should return false when item instance id is DCB_INSTANCE_ID and item holdings record id is not DCB_HOLDINGS_RECORD_ID', () => { + const item = { + instanceId: DCB_INSTANCE_ID, + holdingsRecordId: 'test', + }; + expect(isDCBItem(item)).toBeFalsy(); + }); + + it('should return false when item instance id is not DCB_INSTANCE_ID and item holdings record id is DCB_HOLDINGS_RECORD_ID', () => { + const item = { + instanceId: 'test', + holdingsRecordId: DCB_HOLDINGS_RECORD_ID, + }; + expect(isDCBItem(item)).toBeFalsy(); + }); + + it('should return false when item instance id is not DCB_INSTANCE_ID and item holdings record id is not DCB_HOLDINGS_RECORD_ID', () => { + const item = { + instanceId: 'test', + holdingsRecordId: 'test', + }; + expect(isDCBItem(item)).toBeFalsy(); + }); +}); From 124c6ce5dcdc1eaf3fed2764336454e7114bb231 Mon Sep 17 00:00:00 2001 From: Priyanka Date: Fri, 1 Dec 2023 07:08:57 +0530 Subject: [PATCH 2/3] UICHKIN-403 - fix test failures --- src/util.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util.test.js b/src/util.test.js index b42851a..8b187e2 100644 --- a/src/util.test.js +++ b/src/util.test.js @@ -13,6 +13,7 @@ import { getCheckinSettings, shouldConfirmStatusModalBeShown, isDcbUser, + isDCBItem, } from './util'; import { From 5e85a61fb5830997b02bd452fd43c211688c6e29 Mon Sep 17 00:00:00 2001 From: Priyanka Date: Fri, 1 Dec 2023 15:06:04 +0530 Subject: [PATCH 3/3] UICHKIN-403 - Conditional hide scanned record action menu options for DCB borrowing and Pickup roles. --- src/CheckIn.js | 23 ++++++++++++++--------- src/consts.js | 6 +----- src/util.js | 4 ++-- src/util.test.js | 1 + 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/CheckIn.js b/src/CheckIn.js index 99e7c80..568b825 100644 --- a/src/CheckIn.js +++ b/src/CheckIn.js @@ -305,13 +305,14 @@ class CheckIn extends React.Component { timezone, locale, }, + scannedItems, } = this.props; - console.log('props ', this.props); const isCheckInNote = element => element.noteType === 'Check in'; const checkinNotePresent = get(loan.item, ['circulationNotes'], []).some(isCheckInNote); const loanOpenRequest = loan?.staffSlipContext?.request ?? {}; const isVirtualUser = isDcbUser(loan?.borrower); + const isVirtualItem = isDCBItem(get(scannedItems, [0, 'item'])); const trigger = ({ getTriggerProps, triggerRef }) => ( }
- + { + !isVirtualItem && ( + + ) + }
{!isEmpty(loanOpenRequest) &&
diff --git a/src/consts.js b/src/consts.js index 9661ad4..4636c80 100644 --- a/src/consts.js +++ b/src/consts.js @@ -58,13 +58,9 @@ export const cancelFeeClaimReturned = { export const MAX_RECORDS = '1000'; export const DCB_USER_LASTNAME = 'DcbSystem'; -export const DCB = 'dcb'; export const DCB_USER = { - personal: { - lastName: DCB_USER_LASTNAME, - }, - type: DCB, + lastName: DCB_USER_LASTNAME, }; export const DCB_INSTANCE_ID = '9d1b77e4-f02e-4b7f-b296-3f2042ddac54'; diff --git a/src/util.js b/src/util.js index 3deef04..798968f 100644 --- a/src/util.js +++ b/src/util.js @@ -5,7 +5,7 @@ import { } from 'lodash'; import { - DCB_USER_LASTNAME, + DCB_USER, statuses, DCB_INSTANCE_ID, DCB_HOLDINGS_RECORD_ID, @@ -169,7 +169,7 @@ export function shouldConfirmStatusModalBeShown(item) { ], item?.status?.name); } -export const isDcbUser = (user) => user?.personal?.lastName === DCB_USER_LASTNAME && user.type === 'dcb'; +export const isDcbUser = (user) => user?.lastName === DCB_USER.lastName; export const isDCBItem = (item) => item.instanceId === DCB_INSTANCE_ID && item.holdingsRecordId === DCB_HOLDINGS_RECORD_ID; diff --git a/src/util.test.js b/src/util.test.js index b42851a..8b187e2 100644 --- a/src/util.test.js +++ b/src/util.test.js @@ -13,6 +13,7 @@ import { getCheckinSettings, shouldConfirmStatusModalBeShown, isDcbUser, + isDCBItem, } from './util'; import {