Skip to content

Commit

Permalink
backoffice: DocumentItems: Add columnFormat parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 authored and kpsherva committed Jun 14, 2024
1 parent b55e609 commit f840112
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ export { SectionInstallation } from '@pages/frontsite/Home/Sections/SectionInsta
export { PaymentInformation } from '@components/backoffice/PaymentInformation';
export { OrderLine } from '@pages/backoffice/Acquisition/Order/OrderDetails/OrderLines';
export { formatPrice } from '@api/utils';
export { Loader } from '@components/Loader';
export { Error } from '@components/Error';
export { SeeAllButton } from '@components/backoffice/buttons/SeeAllButton';
export { DocumentItems } from '@pages/backoffice/Document/DocumentDetails/DocumentItems';
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ class DocumentItems extends Component {
return `${row.metadata.internal_location.name} (${row.metadata.internal_location.location.name})`;
};

renderTable(data) {
const { showMaxItems } = this.props;
const columns = [
getColumnFormat = () => {
return [
{
title: 'Barcode',
field: 'metadata.barcode',
Expand Down Expand Up @@ -76,6 +75,12 @@ class DocumentItems extends Component {
},
},
];
};

renderTable(data) {
const { showMaxItems, columnFormat } = this.props;
const columns =
columnFormat !== null ? columnFormat() : this.getColumnFormat();
return (
<ResultsTable
data={data.hits}
Expand Down Expand Up @@ -105,12 +110,14 @@ DocumentItems.propTypes = {
showMaxItems: PropTypes.number,
isLoading: PropTypes.bool,
error: PropTypes.object,
columnFormat: PropTypes.func,
};

DocumentItems.defaultProps = {
showMaxItems: 5,
isLoading: false,
error: null,
columnFormat: null,
};

export default Overridable.component(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`DocumentItems tests should load the DocumentItems component 1`] = `
<DocumentItems
columnFormat={null}
documentDetails={
Object {
"metadata": Object {
Expand Down Expand Up @@ -87,6 +88,7 @@ exports[`DocumentItems tests should render item 1`] = `
fetchDocumentItems={[Function]}
>
<DocumentItems
columnFormat={null}
documentDetails={
Object {
"metadata": Object {
Expand Down Expand Up @@ -818,6 +820,7 @@ exports[`DocumentItems tests should render show a message with no items 1`] = `
fetchDocumentItems={[Function]}
>
<DocumentItems
columnFormat={null}
documentDetails={
Object {
"metadata": Object {
Expand Down Expand Up @@ -1012,6 +1015,7 @@ exports[`DocumentItems tests should render the see all button when showing only
showMaxItems={1}
>
<DocumentItems
columnFormat={null}
documentDetails={
Object {
"metadata": Object {
Expand Down

0 comments on commit f840112

Please sign in to comment.