-
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.
UIIN-2793: Populate Acquisitions accordion on instance when central o…
…rdering is active
- Loading branch information
1 parent
4a86d95
commit 89f6fc9
Showing
8 changed files
with
239 additions
and
51 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
102 changes: 61 additions & 41 deletions
102
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
3 changes: 3 additions & 0 deletions
3
src/Instance/InstanceDetails/InstanceAcquisition/TenantAcquisition.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; | ||
} |
58 changes: 58 additions & 0 deletions
58
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,58 @@ | ||
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'; | ||
|
||
const visibleColumns = ['poLineNumber', 'orderStatus', 'polReceiptStatus', 'dateOrdered', 'acqUnit', 'orderType']; | ||
const columnMapping = { | ||
poLineNumber: <FormattedMessage id="ui-inventory.acq.polNumber" />, | ||
orderStatus: <FormattedMessage id="ui-inventory.acq.orderStatus" />, | ||
polReceiptStatus: <FormattedMessage id="ui-inventory.acq.receiptStatus" />, | ||
dateOrdered: <FormattedMessage id="ui-inventory.acq.dateOpened" />, | ||
acqUnit: <FormattedMessage id="ui-inventory.acq.acqUnit" />, | ||
orderType: <FormattedMessage id="ui-inventory.acq.orderType" />, | ||
}; | ||
const formatter = { | ||
poLineNumber: i => <Link to={`/orders/lines/view/${i.id}`}>{i.poLineNumber}</Link>, | ||
orderStatus: i => ( | ||
<> | ||
{i.order?.workflowStatus ? <FormattedMessage id={`ui-inventory.acq.orderStatus.${i.order.workflowStatus}`} /> : <NoValue />} | ||
{i.order?.orderCloseReason?.reason && ` - ${i.order.orderCloseReason.reason}`} | ||
</> | ||
), | ||
polReceiptStatus: i => <FormattedMessage id={`ui-inventory.acq.receiptStatus.${i.receiptStatus}`} />, | ||
dateOrdered: i => getDateWithTime(i.order?.dateOrdered), | ||
acqUnit: i => i.order?.acqUnits?.map(u => u.name)?.join(', ') || <NoValue />, | ||
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