@inveniosoftware/react-invenio-app-ils 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -398,6 +398,12 @@ const RECORDS_CONFIG = {
398
398
  iconClass: 'dolly'
399
399
  }
400
400
  },
401
+ deliveryMethodSelfCheckout: {
402
+ 'SELF-CHECKOUT': {
403
+ text: 'SELF-CHECKOUT',
404
+ iconClass: 'shopping basket'
405
+ }
406
+ },
401
407
  extensionsMaxCount: 3,
402
408
  loanWillExpireDays: 7,
403
409
  loanActiveStates: ['ITEM_AT_DESK', 'ITEM_ON_LOAN', 'ITEM_IN_TRANSIT_FOR_PICKUP', 'ITEM_IN_TRANSIT_TO_HOUSE'],
@@ -3405,6 +3411,7 @@ const serializer$4 = {
3405
3411
 
3406
3412
  const apiPaths$1 = {
3407
3413
  checkout: '/circulation/loans/checkout',
3414
+ selfCheckout: '/circulation/loans/self-checkout',
3408
3415
  notificationOverdue: '/circulation/loans/:loanPid/notification-overdue',
3409
3416
  item: '/circulation/loans/:loanPid',
3410
3417
  list: '/circulation/loans/',
@@ -3498,6 +3505,24 @@ const doCheckout = async function (documentPid, itemPid, patronPid) {
3498
3505
  response.data = serializer$4.fromJSON(response.data);
3499
3506
  return response;
3500
3507
  };
3508
+ const doSelfCheckoutSearchItem = async barcode => {
3509
+ const response = await http.get(`${apiPaths$1.selfCheckout}?barcode=${barcode}`);
3510
+ response.data = serializer$4.fromJSON(response.data);
3511
+ return response;
3512
+ };
3513
+ const doSelfCheckout = async (documentPid, itemPid, patronPid) => {
3514
+ const currentUser = sessionManager.user;
3515
+ const payload = {
3516
+ document_pid: documentPid,
3517
+ item_pid: itemPid,
3518
+ patron_pid: patronPid,
3519
+ transaction_location_pid: `${currentUser.locationPid}`,
3520
+ transaction_user_pid: `${currentUser.id}`
3521
+ };
3522
+ const response = await http.post(apiPaths$1.selfCheckout, payload);
3523
+ response.data = serializer$4.fromJSON(response.data);
3524
+ return response;
3525
+ };
3501
3526
  const assignItemToLoan$1 = async (itemPid, loanPid) => {
3502
3527
  const path = generatePath(apiPaths$1.replaceItem, {
3503
3528
  loanPid: loanPid
@@ -3678,6 +3703,8 @@ const loanApi = {
3678
3703
  doAction: doAction,
3679
3704
  doRequest: doRequest,
3680
3705
  doCheckout: doCheckout,
3706
+ doSelfCheckout: doSelfCheckout,
3707
+ doSelfCheckoutSearchItem: doSelfCheckoutSearchItem,
3681
3708
  sendOverdueLoansNotificationReminder: sendOverdueLoansNotificationReminder$1,
3682
3709
  serializer: serializer$4,
3683
3710
  updateDates: updateDates,
@@ -12121,6 +12148,7 @@ class LoanListEntry extends Component {
12121
12148
  const patronPid = loan.metadata.patron_pid;
12122
12149
  const delivery = _get(loan.metadata.delivery, 'method');
12123
12150
  const deliveryMethod = delivery && loan.metadata.state === 'PENDING' ? invenioConfig.CIRCULATION.deliveryMethods[delivery] : '';
12151
+ const isSelfCheckout = delivery === 'SELF-CHECKOUT';
12124
12152
  return /*#__PURE__*/React.createElement(Item, null, /*#__PURE__*/React.createElement(Item.Content, null, loan.metadata.is_overdue && /*#__PURE__*/React.createElement(Label, {
12125
12153
  color: "red"
12126
12154
  }, "Overdue"), /*#__PURE__*/React.createElement(Item.Header, {
@@ -12155,8 +12183,10 @@ class LoanListEntry extends Component {
12155
12183
  }, loan.metadata.extension_count || '0'), /*#__PURE__*/React.createElement(List.Content, null, /*#__PURE__*/React.createElement("label", null, " Extensions"))))), /*#__PURE__*/React.createElement(Grid.Column, {
12156
12184
  width: 2,
12157
12185
  textAlign: "center"
12158
- }, deliveryMethod && /*#__PURE__*/React.createElement(React.Fragment, null, delivery, ' ', deliveryMethod.iconClass && /*#__PURE__*/React.createElement(Icon, {
12186
+ }, deliveryMethod ? /*#__PURE__*/React.createElement(React.Fragment, null, delivery, ' ', deliveryMethod.iconClass && /*#__PURE__*/React.createElement(Icon, {
12159
12187
  className: deliveryMethod.iconClass
12188
+ })) : isSelfCheckout && /*#__PURE__*/React.createElement(React.Fragment, null, delivery, ' ', /*#__PURE__*/React.createElement(Icon, {
12189
+ className: invenioConfig.CIRCULATION.deliveryMethodSelfCheckout[delivery].iconClass
12160
12190
  }))), /*#__PURE__*/React.createElement(Grid.Column, {
12161
12191
  computer: 3,
12162
12192
  largeScreen: 3
@@ -24829,7 +24859,7 @@ const deleteItem = itemPid => {
24829
24859
  }
24830
24860
  };
24831
24861
  };
24832
- const checkoutItem$2 = function (documentPid, itemPid, patronPid) {
24862
+ const checkoutItem$1 = function (documentPid, itemPid, patronPid) {
24833
24863
  let force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
24834
24864
  return async dispatch => {
24835
24865
  dispatch({
@@ -25029,7 +25059,7 @@ const mapDispatchToProps$J = dispatch => ({
25029
25059
  deleteItem: itemPid => dispatch(deleteItem(itemPid)),
25030
25060
  checkoutItem: function (documentPid, itemPid, patronPid) {
25031
25061
  let force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
25032
- return dispatch(checkoutItem$2(documentPid, itemPid, patronPid, force));
25062
+ return dispatch(checkoutItem$1(documentPid, itemPid, patronPid, force));
25033
25063
  }
25034
25064
  });
25035
25065
  const ItemActionMenu = connect(mapStateToProps$W, mapDispatchToProps$J)(ItemActionMenu$1);
@@ -25410,7 +25440,7 @@ const mapDispatchToProps$I = dispatch => ({
25410
25440
  deleteItem: itemPid => dispatch(deleteItem(itemPid)),
25411
25441
  checkoutItem: function (documentPid, itemPid, patronPid) {
25412
25442
  let force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
25413
- return dispatch(checkoutItem$2(documentPid, itemPid, patronPid, force));
25443
+ return dispatch(checkoutItem$1(documentPid, itemPid, patronPid, force));
25414
25444
  }
25415
25445
  });
25416
25446
  const ItemMetadata$1 = connect(mapStateToProps$U, mapDispatchToProps$I)(ItemMetadata$2);
@@ -26583,7 +26613,7 @@ class LoanMetadata$1 extends Component {
26583
26613
  getDelivery(_delivery) {
26584
26614
  const delivery = _get(_delivery, 'method');
26585
26615
  if (delivery) {
26586
- const deliveryMethod = invenioConfig.CIRCULATION.deliveryMethods[delivery];
26616
+ const deliveryMethod = invenioConfig.CIRCULATION.deliveryMethods[delivery] || invenioConfig.CIRCULATION.deliveryMethodSelfCheckout[delivery];
26587
26617
  return /*#__PURE__*/React.createElement(React.Fragment, null, deliveryMethod.text, ' ', deliveryMethod.iconClass && /*#__PURE__*/React.createElement(Icon, {
26588
26618
  className: deliveryMethod.iconClass
26589
26619
  }));
@@ -29529,7 +29559,7 @@ const CLEAR_SEARCH = 'itemsSearchBarcode/CLEAR_SEARCH';
29529
29559
  const IS_LOADING$h = 'patronItemCheckout/IS_LOADING';
29530
29560
  const SUCCESS$h = 'patronItemCheckout/SUCCESS';
29531
29561
  const HAS_ERROR$h = 'patronItemCheckout/ERROR';
29532
- const checkoutItem$1 = function (documentPid, itemPid, patronPid) {
29562
+ const checkoutItem = function (documentPid, itemPid, patronPid) {
29533
29563
  let force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
29534
29564
  return async dispatch => {
29535
29565
  dispatch({
@@ -29570,7 +29600,7 @@ const checkoutItem$1 = function (documentPid, itemPid, patronPid) {
29570
29600
  const mapDispatchToProps$t = dispatch => ({
29571
29601
  checkoutItem: function (documentPid, itemPid, patronPid) {
29572
29602
  let force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
29573
- return dispatch(checkoutItem$1(documentPid, itemPid, patronPid, force));
29603
+ return dispatch(checkoutItem(documentPid, itemPid, patronPid, force));
29574
29604
  }
29575
29605
  });
29576
29606
  const mapStateToProps$E = state => ({
@@ -29732,7 +29762,7 @@ const mapStateToProps$D = state => ({
29732
29762
  const mapDispatchToProps$s = dispatch => ({
29733
29763
  checkoutItem: function (documentPid, itemPid, patronPid) {
29734
29764
  let force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
29735
- return dispatch(checkoutItem$1(documentPid, itemPid, patronPid, force));
29765
+ return dispatch(checkoutItem(documentPid, itemPid, patronPid, force));
29736
29766
  }
29737
29767
  });
29738
29768
  const ItemsResultsList = connect(mapStateToProps$D, mapDispatchToProps$s)(ItemsResultsList$1);
@@ -29858,7 +29888,7 @@ const fetchAndCheckoutIfOne = (barcode, patronPid, onSuccess) => {
29858
29888
  type: recordToPidType(itemToCheckout),
29859
29889
  value: itemToCheckout.metadata.pid
29860
29890
  };
29861
- dispatch(checkoutItem$1(documentPid, itemPid, patronPid, true));
29891
+ dispatch(checkoutItem(documentPid, itemPid, patronPid, true));
29862
29892
  onSuccess();
29863
29893
  }
29864
29894
  } catch (error) {
@@ -29893,7 +29923,7 @@ const mapDispatchToProps$r = dispatch => ({
29893
29923
  clearResults: () => dispatch(clearResults()),
29894
29924
  checkoutItem: function (documentPid, itemPid, patronPid) {
29895
29925
  let force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
29896
- return dispatch(checkoutItem$1(documentPid, itemPid, patronPid, force));
29926
+ return dispatch(checkoutItem(documentPid, itemPid, patronPid, force));
29897
29927
  }
29898
29928
  });
29899
29929
  const mapStateToProps$C = state => ({
@@ -37724,11 +37754,11 @@ class SelfCheckoutModal$1 extends React.Component {
37724
37754
  size: "large",
37725
37755
  centered: true,
37726
37756
  onClose: () => toggleModal(false)
37727
- }, /*#__PURE__*/React.createElement(Modal.Header, null, `You are about to checkout a book with barcode:
37757
+ }, /*#__PURE__*/React.createElement(Modal.Header, null, `You are about to checkout the literature with barcode:
37728
37758
  ${item === null || item === void 0 ? void 0 : item.metadata.barcode}`), /*#__PURE__*/React.createElement(Modal.Content, null, /*#__PURE__*/React.createElement(DocumentCard, {
37729
37759
  item: item
37730
37760
  }), /*#__PURE__*/React.createElement(ManualCheckout, {
37731
- label: "Wrong book?",
37761
+ label: "Wrong literature?",
37732
37762
  autofocus: true,
37733
37763
  show: true,
37734
37764
  onBarcodeInput: onBarcodeDetected
@@ -37766,22 +37796,19 @@ const notifyResultMessage = message => {
37766
37796
  dispatch(sendWarningNotification(message));
37767
37797
  };
37768
37798
  };
37769
- const searchItem = async (dispatch, term) => {
37770
- const upperCasedTerm = term.toUpperCase();
37771
- const response = await itemApi.list(itemApi.query().withBarcode(upperCasedTerm).qs());
37772
- const item = _first(response.data.hits) || null;
37773
- dispatch({
37774
- type: SEARCH_ITEM_SUCCESS,
37775
- payload: item
37776
- });
37777
- };
37778
37799
  const selfCheckOutSearch = term => {
37779
37800
  return async dispatch => {
37780
37801
  dispatch({
37781
37802
  type: SEARCH_IS_LOADING
37782
37803
  });
37783
37804
  try {
37784
- await searchItem(dispatch, term);
37805
+ const upperCasedTerm = term.toUpperCase();
37806
+ const response = await loanApi.doSelfCheckoutSearchItem(upperCasedTerm);
37807
+ const item = response.data || null;
37808
+ dispatch({
37809
+ type: SEARCH_ITEM_SUCCESS,
37810
+ payload: item
37811
+ });
37785
37812
  } catch (error) {
37786
37813
  dispatch({
37787
37814
  type: SEARCH_HAS_ERROR,
@@ -37791,16 +37818,13 @@ const selfCheckOutSearch = term => {
37791
37818
  }
37792
37819
  };
37793
37820
  };
37794
- const checkoutItem = (documentPid, itemPid, patronPid) => {
37821
+ const selfCheckOut = (documentPid, itemPid, patronPid) => {
37795
37822
  return async dispatch => {
37796
37823
  try {
37797
- const response = await loanApi.doCheckout(documentPid, itemPid, patronPid);
37798
- const {
37799
- pid
37800
- } = response.data.metadata;
37801
- const linkToLoan = /*#__PURE__*/React.createElement("p", null, "The loan ", pid, " has been created by you! You can view all your current loans on your ", /*#__PURE__*/React.createElement(Link$1, {
37824
+ await loanApi.doSelfCheckout(documentPid, itemPid, patronPid);
37825
+ const linkToLoan = /*#__PURE__*/React.createElement("p", null, "Self-checkout completed! You can view all your current loans on your", ' ', /*#__PURE__*/React.createElement(Link$1, {
37802
37826
  to: FrontSiteRoutes.patronProfile
37803
- }, "profile"), ' ', "page.");
37827
+ }, "profile"), " page.");
37804
37828
  dispatch(sendSuccessNotification('Success!', linkToLoan));
37805
37829
  } catch (error) {
37806
37830
  dispatch(sendErrorNotification(error));
@@ -37809,7 +37833,7 @@ const checkoutItem = (documentPid, itemPid, patronPid) => {
37809
37833
  };
37810
37834
 
37811
37835
  const mapDispatchToProps$a = dispatch => ({
37812
- checkoutItem: (documentPid, itemPid, patronPid) => dispatch(checkoutItem(documentPid, itemPid, patronPid))
37836
+ checkoutItem: (documentPid, itemPid, patronPid) => dispatch(selfCheckOut(documentPid, itemPid, patronPid))
37813
37837
  });
37814
37838
  const mapStateToProps$b = state => ({
37815
37839
  user: state.authenticationManagement.data,
@@ -37843,49 +37867,9 @@ class SelfCheckout$1 extends React.Component {
37843
37867
  selfCheckOutSearch
37844
37868
  } = this.props;
37845
37869
  await selfCheckOutSearch(detectedBarcode);
37846
-
37847
- // open modal if item is loanable
37848
- const shouldShowModal = this.isItemLoanable(detectedBarcode);
37849
- if (shouldShowModal) {
37850
- this.toggleModal(true);
37851
- } else {
37852
- this.toggleModal(false);
37853
- }
37870
+ this.toggleModal(true);
37854
37871
  }
37855
37872
  };
37856
- this.itemStatus = item => ({
37857
- canCirculate: () => invenioConfig.ITEMS.canCirculateStatuses.includes(item.metadata.status),
37858
- isOnShelf: () => !item.metadata.circulation.state // on shelf if circulation.state doesn't exist
37859
- });
37860
- this.isItemLoanable = itemBarcode => {
37861
- const {
37862
- user,
37863
- item,
37864
- notifyResultMessage
37865
- } = this.props;
37866
- var resultMessage = `Book with barcode ${itemBarcode} not found.`;
37867
- if (!_isEmpty(item)) {
37868
- if (this.itemStatus(item).canCirculate()) {
37869
- if (this.itemStatus(item).isOnShelf()) {
37870
- return true;
37871
- } else {
37872
- if (item.metadata.circulation.patron_pid === user.id.toString()) {
37873
- resultMessage = `You already loaned this book with barcode: ${itemBarcode}!`;
37874
- } else {
37875
- resultMessage = `Book with barcode: ${itemBarcode} is currently on loan!`;
37876
- }
37877
- }
37878
- } else {
37879
- var _item$metadata;
37880
- const status = _find(invenioConfig.ITEMS.statuses, {
37881
- value: (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.status
37882
- });
37883
- resultMessage = `Book with barcode: ${itemBarcode} is ${status === null || status === void 0 ? void 0 : status.text}!`;
37884
- }
37885
- }
37886
- notifyResultMessage(resultMessage);
37887
- return false;
37888
- };
37889
37873
  this.renderInstructions = () => {
37890
37874
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
37891
37875
  as: "h3"
@@ -37937,13 +37921,11 @@ class SelfCheckout$1 extends React.Component {
37937
37921
  }), this.renderInstructions());
37938
37922
  }
37939
37923
  }
37940
- SelfCheckout$1.defaultProps = {
37941
- item: null
37942
- };
37943
37924
  var SelfCheckoutComponent = Overridable.component('SelfCheckout', SelfCheckout$1);
37944
37925
 
37945
37926
  const mapDispatchToProps$9 = dispatch => ({
37946
37927
  selfCheckOutSearch: term => dispatch(selfCheckOutSearch(term)),
37928
+ selfCheckOut: term => dispatch(selfCheckOut(term)),
37947
37929
  notifyResultMessage: message => dispatch(notifyResultMessage(message))
37948
37930
  });
37949
37931
  const mapStateToProps$a = state => ({