-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into UIIN-2896
- Loading branch information
Showing
41 changed files
with
355 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/Instance/InstanceDetails/InstanceAcquisition/InstanceAcquisition.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.tenantAcquisitionAccordion { | ||
padding-left: 15px; | ||
} |
106 changes: 65 additions & 41 deletions
106
src/Instance/InstanceDetails/InstanceAcquisition/InstanceAcquisition.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/Instance/InstanceDetails/InstanceAcquisition/TenantAcquisition.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { | ||
MultiColumnList, | ||
NoValue, | ||
} from '@folio/stripes/components'; | ||
|
||
import { getDateWithTime } from '../../../utils'; | ||
import { ACQUISITION_COLUMN_NAMES } from '../../../constants'; | ||
|
||
const visibleColumns = [ | ||
ACQUISITION_COLUMN_NAMES.poLineNumber, | ||
ACQUISITION_COLUMN_NAMES.orderStatus, | ||
ACQUISITION_COLUMN_NAMES.polReceiptStatus, | ||
ACQUISITION_COLUMN_NAMES.dateOrdered, | ||
ACQUISITION_COLUMN_NAMES.acqUnit, | ||
ACQUISITION_COLUMN_NAMES.orderType, | ||
]; | ||
|
||
const columnMapping = { | ||
[ACQUISITION_COLUMN_NAMES.poLineNumber]: <FormattedMessage id="ui-inventory.acq.polNumber" />, | ||
[ACQUISITION_COLUMN_NAMES.orderStatus]: <FormattedMessage id="ui-inventory.acq.orderStatus" />, | ||
[ACQUISITION_COLUMN_NAMES.polReceiptStatus]: <FormattedMessage id="ui-inventory.acq.receiptStatus" />, | ||
[ACQUISITION_COLUMN_NAMES.dateOrdered]: <FormattedMessage id="ui-inventory.acq.dateOpened" />, | ||
[ACQUISITION_COLUMN_NAMES.acqUnit]: <FormattedMessage id="ui-inventory.acq.acqUnit" />, | ||
[ACQUISITION_COLUMN_NAMES.orderType]: <FormattedMessage id="ui-inventory.acq.orderType" />, | ||
}; | ||
|
||
const formatter = { | ||
[ACQUISITION_COLUMN_NAMES.poLineNumber]: i => <Link to={`/orders/lines/view/${i.id}`}>{i.poLineNumber}</Link>, | ||
[ACQUISITION_COLUMN_NAMES.orderStatus]: i => ( | ||
<> | ||
{i.order?.workflowStatus ? <FormattedMessage id={`ui-inventory.acq.orderStatus.${i.order.workflowStatus}`} /> : <NoValue />} | ||
{i.order?.orderCloseReason?.reason && ` - ${i.order.orderCloseReason.reason}`} | ||
</> | ||
), | ||
[ACQUISITION_COLUMN_NAMES.polReceiptStatus]: i => <FormattedMessage id={`ui-inventory.acq.receiptStatus.${i.receiptStatus}`} />, | ||
[ACQUISITION_COLUMN_NAMES.dateOrdered]: i => getDateWithTime(i.order?.dateOrdered), | ||
[ACQUISITION_COLUMN_NAMES.acqUnit]: i => i.order?.acqUnits?.map(u => u.name)?.join(', ') || <NoValue />, | ||
[ACQUISITION_COLUMN_NAMES.orderType]: i => (i.order?.orderType ? <FormattedMessage id={`ui-inventory.acq.orderType.${i.order.orderType}`} /> : <NoValue />), | ||
}; | ||
|
||
const TenantAcquisition = ({ | ||
acquisitions, | ||
isLoading, | ||
tenantId, | ||
}) => ( | ||
<MultiColumnList | ||
id={`${tenantId}list-instance-acquisitions`} | ||
loading={isLoading} | ||
contentData={acquisitions} | ||
visibleColumns={visibleColumns} | ||
columnMapping={columnMapping} | ||
formatter={formatter} | ||
interactive={false} | ||
/> | ||
); | ||
|
||
TenantAcquisition.propTypes = { | ||
acquisitions: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
isLoading: PropTypes.bool.isRequired, | ||
tenantId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default TenantAcquisition; |
30 changes: 30 additions & 0 deletions
30
src/Instance/InstanceDetails/InstanceAcquisition/TenantAcquisition.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
|
||
import { screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import '../../../../test/jest/__mock__'; | ||
import { renderWithIntl } from '../../../../test/jest/helpers'; | ||
|
||
import { resultData, line } from './fixtures'; | ||
import TenantAcquisition from './TenantAcquisition'; | ||
|
||
const renderTenantAcquisition = () => ( | ||
renderWithIntl( | ||
<Router> | ||
<TenantAcquisition | ||
acquisitions={resultData} | ||
isLoading={false} | ||
tenantId="diku" | ||
/> | ||
</Router> | ||
) | ||
); | ||
|
||
describe('TenantAcquisition', () => { | ||
it('should display instance acquisition data', () => { | ||
renderTenantAcquisition(); | ||
|
||
expect(screen.getByText(line.poLineNumber)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.