Skip to content

Commit

Permalink
frontsite: SelfCheckoutModal: Handle non existing item barcode
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 authored and kpsherva committed Jun 18, 2024
1 parent ea426b3 commit 162c9a1
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DocumentCard } from './DocumentCard';
import { Modal, Button } from 'semantic-ui-react';
import { goTo } from '@history';
import { FrontSiteRoutes } from '@routes/urls';
import _isEmpty from 'lodash/isEmpty';

export default class SelfCheckoutModal extends React.Component {
checkout = () => {
Expand All @@ -31,9 +32,10 @@ export default class SelfCheckoutModal extends React.Component {

render() {
const { isLoading, item, modalOpened, toggleModal } = this.props;
const itemBarcode = item?.metadata.barcode;

return item ? (
if (_isEmpty(item)) {
return null;
}
return (
<Loader isLoading={isLoading}>
<Modal
open={modalOpened}
Expand All @@ -43,7 +45,7 @@ export default class SelfCheckoutModal extends React.Component {
>
<Modal.Header>
{`You are about to checkout a book with barcode:
${itemBarcode}`}
${item?.metadata.barcode}`}
</Modal.Header>
<Modal.Content>
<DocumentCard item={item} />
Expand Down Expand Up @@ -73,7 +75,7 @@ export default class SelfCheckoutModal extends React.Component {
</Modal.Actions>
</Modal>
</Loader>
) : null;
);
}
}

Expand Down

0 comments on commit 162c9a1

Please sign in to comment.