@spokane-folio/security-incident 1.0.28
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/.eslintrc +32 -0
- package/.github/workflows/CODEOWNERS +8 -0
- package/.github/workflows/pr-validation.yml +44 -0
- package/.github/workflows/release.yml +64 -0
- package/.prettierrc +6 -0
- package/.stripesclirc +4 -0
- package/CHANGELOG.md +8 -0
- package/CONTRIBUTING.md +4 -0
- package/LICENSE +201 -0
- package/README.md +16 -0
- package/administrator-documentation/roles-and-permissions.md +65 -0
- package/administrator-documentation/track-settings-admin-guide-sketch.md +192 -0
- package/administrator-documentation/using-the-application.md +192 -0
- package/icons/app.png +0 -0
- package/icons/app.svg +1 -0
- package/icons/playButton.png +0 -0
- package/icons/profilePicThumbnail.png +0 -0
- package/jest.config.js +10 -0
- package/module-descriptor.json +75 -0
- package/output/service-worker.js +0 -0
- package/package.json +146 -0
- package/src/components/incidents/ColumnChooser.js +37 -0
- package/src/components/incidents/CreateMedia.js +132 -0
- package/src/components/incidents/CreatePane.js +1215 -0
- package/src/components/incidents/CreatePane.test.js +138 -0
- package/src/components/incidents/CreateReport.js +102 -0
- package/src/components/incidents/DetailsPane.js +1267 -0
- package/src/components/incidents/DetailsPane.test.js +150 -0
- package/src/components/incidents/EditPane.js +2334 -0
- package/src/components/incidents/EditPane.test.js +187 -0
- package/src/components/incidents/GetDetails.js +55 -0
- package/src/components/incidents/GetListDQLinkIncident.js +81 -0
- package/src/components/incidents/GetListDynamicQuery.js +66 -0
- package/src/components/incidents/GetLocations.js +57 -0
- package/src/components/incidents/GetMedia.js +98 -0
- package/src/components/incidents/GetName.js +111 -0
- package/src/components/incidents/GetNameCreatedBy.js +94 -0
- package/src/components/incidents/GetOrgLocaleSettings.js +61 -0
- package/src/components/incidents/GetPatronGroups.js +52 -0
- package/src/components/incidents/GetSelf.js +65 -0
- package/src/components/incidents/GetSummary.js +110 -0
- package/src/components/incidents/IncidentTypeCard.js +53 -0
- package/src/components/incidents/IncidentTypeCard.test.js +133 -0
- package/src/components/incidents/IncidentsPaneset.js +810 -0
- package/src/components/incidents/IncidentsPaneset.test.js +128 -0
- package/src/components/incidents/LinkedIncident.js +86 -0
- package/src/components/incidents/ModalAddMedia.js +262 -0
- package/src/components/incidents/ModalAddMedia.test.js +97 -0
- package/src/components/incidents/ModalAttentionDecOfService.js +111 -0
- package/src/components/incidents/ModalCustomWitness.js +469 -0
- package/src/components/incidents/ModalCustomWitness.test.js +147 -0
- package/src/components/incidents/ModalCustomerDetails.js +480 -0
- package/src/components/incidents/ModalCustomerDetails.test.js +116 -0
- package/src/components/incidents/ModalDescribeCustomer.js +361 -0
- package/src/components/incidents/ModalDescribeCustomer.test.js +156 -0
- package/src/components/incidents/ModalDirtyFormWarn.js +62 -0
- package/src/components/incidents/ModalLinkIncident.js +1213 -0
- package/src/components/incidents/ModalLinkIncidentStyle.css +32 -0
- package/src/components/incidents/ModalSelectIncidentTypes.js +178 -0
- package/src/components/incidents/ModalSelectIncidentTypes.test.js +273 -0
- package/src/components/incidents/ModalSelectKnownCustomer.js +395 -0
- package/src/components/incidents/ModalSelectWitness.js +406 -0
- package/src/components/incidents/ModalSelectWitness.test.js +308 -0
- package/src/components/incidents/ModalStyle.css +44 -0
- package/src/components/incidents/ModalTrespass.js +741 -0
- package/src/components/incidents/ModalViewCustomerDetails.js +241 -0
- package/src/components/incidents/ModalViewMedia.js +86 -0
- package/src/components/incidents/ModalViewTrespass.js +210 -0
- package/src/components/incidents/ResultsPane.js +437 -0
- package/src/components/incidents/ResultsPane.test.js +120 -0
- package/src/components/incidents/SearchCustomerOrWitness.js +108 -0
- package/src/components/incidents/Thumbnail.js +72 -0
- package/src/components/incidents/ThumbnailMarkRemoval.js +38 -0
- package/src/components/incidents/ThumbnailSkeleton.js +30 -0
- package/src/components/incidents/ThumbnailStyles.js +49 -0
- package/src/components/incidents/ThumbnailTempPreSave.js +71 -0
- package/src/components/incidents/UpdateReport.js +84 -0
- package/src/components/incidents/__snapshots__/CreatePane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/DetailsPane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/EditPane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/IncidentTypeCard.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/IncidentsPaneset.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalAddMedia.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalCustomerDetails.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalSelectWitness.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ResultsPane.test.js.snap +3 -0
- package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.css +5 -0
- package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.js +51 -0
- package/src/components/incidents/helpers/ProfilePicture/isAValidURL.js +3 -0
- package/src/components/incidents/helpers/ProfilePicture/useProfilePicture.js +127 -0
- package/src/components/incidents/helpers/buildQueryString.js +28 -0
- package/src/components/incidents/helpers/cleanFormValues.js +53 -0
- package/src/components/incidents/helpers/computeEditedCustomers.js +124 -0
- package/src/components/incidents/helpers/convertDateIgnoringTZ.js +8 -0
- package/src/components/incidents/helpers/convertUTCISOToLocalePrettyTime.js +15 -0
- package/src/components/incidents/helpers/convertUTCISOToPrettyDate.js +19 -0
- package/src/components/incidents/helpers/decodeParamsToForm.js +20 -0
- package/src/components/incidents/helpers/deepNormalizeForComparison.js +39 -0
- package/src/components/incidents/helpers/extractFilterString.js +12 -0
- package/src/components/incidents/helpers/formatDateAndTimeToUTCISO.js +14 -0
- package/src/components/incidents/helpers/formatDateToUTCISO.js +14 -0
- package/src/components/incidents/helpers/formatTimeToUTCISO.js +28 -0
- package/src/components/incidents/helpers/getCurrentTime.js +20 -0
- package/src/components/incidents/helpers/getTodayDate.js +12 -0
- package/src/components/incidents/helpers/handlebarsHelpers.js +148 -0
- package/src/components/incidents/helpers/hasFormChangedAtCreate.js +50 -0
- package/src/components/incidents/helpers/hasTopLevelChangeAffectedDeclaration.js +90 -0
- package/src/components/incidents/helpers/hasTopLevelFormChanged.js +111 -0
- package/src/components/incidents/helpers/identifyCurrentTrespassDocs.js +109 -0
- package/src/components/incidents/helpers/isSameHtml.js +13 -0
- package/src/components/incidents/helpers/isValidDateFormat.js +14 -0
- package/src/components/incidents/helpers/isValidTimeInput.js +11 -0
- package/src/components/incidents/helpers/isValidUTCTimeFormat.js +14 -0
- package/src/components/incidents/helpers/parseMMDDYYYY.js +7 -0
- package/src/components/incidents/helpers/parseQueryString.js +16 -0
- package/src/components/incidents/helpers/sortTrespassDocuments.js +44 -0
- package/src/components/incidents/helpers/stripHTML.js +11 -0
- package/src/components/incidents/helpers/trespassDocUtils.js +197 -0
- package/src/components/incidents/helpers/validateTrespassDetails.js +37 -0
- package/src/components/incidents/usePersistedColModalLink.js +70 -0
- package/src/components/incidents/usePersistedColumns.js +70 -0
- package/src/components/incidents/usePersistedSort.js +23 -0
- package/src/components/incidents/usePersistedSortModalLink.js +23 -0
- package/src/contexts/IncidentContext.js +433 -0
- package/src/index.js +61 -0
- package/src/routes/Application.js +13 -0
- package/src/settings/GetIncidentCategories.js +56 -0
- package/src/settings/GetIncidentTypesDetails.js +88 -0
- package/src/settings/GetIncidentTypesIds.js +74 -0
- package/src/settings/GetLocationsInService.js +54 -0
- package/src/settings/GetSingleCustomLocationDetails.js +60 -0
- package/src/settings/GetSingleIncidentTypeDetails.js +60 -0
- package/src/settings/GetTrespassReasons.js +67 -0
- package/src/settings/GetTrespassTemplates.js +51 -0
- package/src/settings/IncidentCategoriesPane.js +285 -0
- package/src/settings/IncidentCategoriesPane.test.js +229 -0
- package/src/settings/IncidentTypeDetailsPane.js +215 -0
- package/src/settings/IncidentTypeDetailsPane.test.js +220 -0
- package/src/settings/IncidentTypeEditPane.js +211 -0
- package/src/settings/IncidentTypeEditPane.test.js +170 -0
- package/src/settings/IncidentTypesPaneset.js +167 -0
- package/src/settings/IncidentTypesPaneset.test.js +124 -0
- package/src/settings/LocationInServiceEditPane.js +320 -0
- package/src/settings/LocationsPaneset.js +415 -0
- package/src/settings/LocationsPaneset.test.js +106 -0
- package/src/settings/ModalDeleteCategory.js +47 -0
- package/src/settings/ModalDeleteIncidentType.js +49 -0
- package/src/settings/ModalDeleteLocationInService.js +49 -0
- package/src/settings/ModalDeleteTrespassReason.js +49 -0
- package/src/settings/ModalPreviewTrespassDoc.js +65 -0
- package/src/settings/ModalTrespassDocTokens.js +83 -0
- package/src/settings/NewIncidentTypePane.js +182 -0
- package/src/settings/PutIncidentType.js +60 -0
- package/src/settings/PutLocationsInService.js +52 -0
- package/src/settings/PutTrespassReasons.js +61 -0
- package/src/settings/PutTrespassTemplate.js +50 -0
- package/src/settings/TrespassDoc.css +17 -0
- package/src/settings/TrespassDocDetailsPane.js +215 -0
- package/src/settings/TrespassDocEditPane.js +538 -0
- package/src/settings/TrespassDocPaneset.js +581 -0
- package/src/settings/TrespassReasonDetailsPane.js +171 -0
- package/src/settings/TrespassReasonEditPane.js +221 -0
- package/src/settings/TrespassReasonsPaneset.js +282 -0
- package/src/settings/__snapshots__/IncidentCategoriesPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypeDetailsPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypeEditPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypesPaneset.test.js.snap +3 -0
- package/src/settings/__snapshots__/LocationsPaneset.test.js.snap +3 -0
- package/src/settings/data/exampleJSON.json +92 -0
- package/src/settings/data/templateTokens.js +396 -0
- package/src/settings/helpers/alphabetize.js +18 -0
- package/src/settings/helpers/getCategoryTitleById.js +13 -0
- package/src/settings/helpers/makeId.js +15 -0
- package/src/settings/index.js +48 -0
- package/stripes.config.js +10 -0
- package/test/jest/__mock__/index.js +8 -0
- package/test/jest/__mock__/intl.mock.js +27 -0
- package/test/jest/__mock__/stripes.mock.js +26 -0
- package/test/jest/__mock__/stripesComponents.mock.js +151 -0
- package/test/jest/__mock__/stripesConfig.mock.js +1 -0
- package/test/jest/__mock__/stripesCore.mock.js +9 -0
- package/test/jest/__mock__/stripesIcon.mock.js +5 -0
- package/test/jest/__mock__/stripesSmartComponents.mock.js +7 -0
- package/test/jest/__mock__/stripesUtils.mock.js +3 -0
- package/test/jest/eslintrc.js +12 -0
- package/test/jest/setupFiles.js +5 -0
- package/translations/ui-security-incident/en_US.json +542 -0
- package/ui-module-acceptance-criteria.md +34 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { act } from 'react-dom/test-utils';
|
|
4
|
+
import CreatePane from './CreatePane';
|
|
5
|
+
|
|
6
|
+
// --- Mocks for External Dependencies ---
|
|
7
|
+
|
|
8
|
+
// Mock react-intl.
|
|
9
|
+
jest.mock('react-intl', () => ({
|
|
10
|
+
useIntl: () => ({
|
|
11
|
+
formatMessage: ({ id }) => id,
|
|
12
|
+
}),
|
|
13
|
+
FormattedMessage: (props) => <span>{props.id}</span>,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
// Mock react-router-dom.
|
|
17
|
+
jest.mock('react-router-dom', () => ({
|
|
18
|
+
useHistory: () => ({ push: jest.fn() }),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
// Mock @folio/stripes/components.
|
|
22
|
+
jest.mock('@folio/stripes/components', () => {
|
|
23
|
+
const React = require('react');
|
|
24
|
+
return {
|
|
25
|
+
Accordion: (props) => <div {...props}>{props.children}</div>,
|
|
26
|
+
AccordionSet: (props) => <div {...props}>{props.children}</div>,
|
|
27
|
+
Button: (props) => <button {...props}>{props.children}</button>,
|
|
28
|
+
Checkbox: (props) => <div {...props}>{props.children}</div>,
|
|
29
|
+
Col: (props) => <div {...props}>{props.children}</div>,
|
|
30
|
+
Datepicker: (props) => <input type="date" {...props} />,
|
|
31
|
+
Editor: (props) => <textarea {...props} />,
|
|
32
|
+
ExpandAllButton: (props) => <button {...props}>{props.children}</button>,
|
|
33
|
+
List: (props) => (
|
|
34
|
+
<ul {...props}>
|
|
35
|
+
{props.items && props.items.map((item, index) => <li key={index}>{item}</li>)}
|
|
36
|
+
</ul>
|
|
37
|
+
),
|
|
38
|
+
Icon: (props) => <span {...props}>{props.icon}</span>,
|
|
39
|
+
Label: (props) => <label {...props}>{props.children}</label>,
|
|
40
|
+
Pane: (props) => <div {...props}>{props.children}</div>,
|
|
41
|
+
PaneHeader: (props) => <div {...props}>{props.children}</div>,
|
|
42
|
+
PaneFooter: (props) => <div {...props}>{props.children}</div>,
|
|
43
|
+
Row: (props) => <div {...props}>{props.children}</div>,
|
|
44
|
+
Select: (props) => <select {...props}>{props.children}</select>,
|
|
45
|
+
Timepicker: (props) => <input type="time" {...props} />,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// --- Mocks for Child Components ---
|
|
50
|
+
|
|
51
|
+
jest.mock('../../settings/GetLocationsInService', () => () => <div>Mock GetLocationsInService</div>);
|
|
52
|
+
jest.mock('../../settings/GetIncidentTypesDetails', () => () => <div>Mock GetIncidentTypesDetails</div>);
|
|
53
|
+
jest.mock('./ModalSelectIncidentTypes', () => () => <div>Mock ModalSelectIncidentTypes</div>);
|
|
54
|
+
jest.mock('./ModalSelectKnownCustomer', () => () => <div>Mock ModalSelectKnownCustomer</div>);
|
|
55
|
+
jest.mock('./ModalSelectWitness', () => () => <div>Mock ModalSelectWitness</div>);
|
|
56
|
+
jest.mock('./ModalDescribeCustomer', () => () => <div>Mock ModalDescribeCustomer</div>);
|
|
57
|
+
jest.mock('./ModalTrespass', () => () => <div>Mock ModalTrespass</div>);
|
|
58
|
+
jest.mock('./ModalCustomerDetails', () => () => <div>Mock ModalCustomerDetails</div>);
|
|
59
|
+
jest.mock('./ModalAddMedia', () => () => <div>Mock ModalAddMedia</div>);
|
|
60
|
+
jest.mock('./CreateMedia', () => () => <div>Mock CreateMedia</div>);
|
|
61
|
+
jest.mock('./GetLocations', () => () => <div>Mock GetLocations</div>);
|
|
62
|
+
jest.mock('./GetSelf', () => () => <div>Mock GetSelf</div>);
|
|
63
|
+
jest.mock('./CreateReport', () => () => <div>Mock CreateReport</div>);
|
|
64
|
+
jest.mock('../../settings/helpers/makeId', () => () => 'mockedId');
|
|
65
|
+
jest.mock('./ThumbnailTempPreSave', () => () => <div>Mock ThumbnailTempPreSave</div>);
|
|
66
|
+
jest.mock('./ModalCustomWitness', () => () => <div>Mock ModalCustomWitness</div>);
|
|
67
|
+
jest.mock('../../settings/GetTrespassTemplates', () => () => <div>Mock GetTrespassTemplates</div>);
|
|
68
|
+
|
|
69
|
+
// --- Mocks for Helper Functions ---
|
|
70
|
+
jest.mock('./helpers/stripHTML', () => jest.fn((str) => str));
|
|
71
|
+
jest.mock('./helpers/getTodayDate', () => jest.fn(() => '01/01/2020'));
|
|
72
|
+
jest.mock('./helpers/isValidDateFormat', () => jest.fn(() => true));
|
|
73
|
+
jest.mock('./helpers/isValidTimeInput', () => jest.fn(() => true));
|
|
74
|
+
jest.mock('./helpers/convertUTCISOToPrettyDate', () => jest.fn((date) => date));
|
|
75
|
+
jest.mock('./helpers/formatDateToUTCISO', () => jest.fn((date) => date));
|
|
76
|
+
jest.mock('./helpers/formatDateAndTimeToUTCISO', () => jest.fn((date, time) => `${date}T${time}`));
|
|
77
|
+
jest.mock('./helpers/getCurrentTime', () => jest.fn(() => '12:00'));
|
|
78
|
+
|
|
79
|
+
// --- Mock for Incident Context ---
|
|
80
|
+
jest.mock('../../contexts/IncidentContext', () => ({
|
|
81
|
+
useIncidents: () => ({
|
|
82
|
+
openModalSelectTypes: jest.fn(),
|
|
83
|
+
closeCreatePane: jest.fn(),
|
|
84
|
+
openModalUnknownCust: jest.fn(),
|
|
85
|
+
openModalSelectKnownCust: jest.fn(),
|
|
86
|
+
openModalSelectWitness: jest.fn(),
|
|
87
|
+
openModalMedia: jest.fn(),
|
|
88
|
+
idForMediaCreate: null,
|
|
89
|
+
setIdForMediaCreate: jest.fn(),
|
|
90
|
+
formDataArrayForMediaCreate: null,
|
|
91
|
+
setFormDataArrayForMediaCreate: jest.fn(),
|
|
92
|
+
selectedCustomers: [],
|
|
93
|
+
setSelectedCustomers: jest.fn(),
|
|
94
|
+
selectedWitnesses: [],
|
|
95
|
+
setSelectedWitnesses: jest.fn(),
|
|
96
|
+
attachmentsData: [],
|
|
97
|
+
setAttachmentsData: jest.fn(),
|
|
98
|
+
self: { id: 'self-id', barcode: 'self-barcode', lastName: 'SelfLast', firstName: 'SelfFirst' },
|
|
99
|
+
openModalTrespass: jest.fn(),
|
|
100
|
+
openModalCustomerDetails: jest.fn(),
|
|
101
|
+
incidentTypesList: [],
|
|
102
|
+
isModalCustomWitness: false,
|
|
103
|
+
openModalCustomWitness: jest.fn(),
|
|
104
|
+
locationsInService: [],
|
|
105
|
+
trespassTemplates: [],
|
|
106
|
+
triggerDocumentError: jest.fn(),
|
|
107
|
+
}),
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
// --- Test Setup ---
|
|
111
|
+
let container = null;
|
|
112
|
+
beforeEach(() => {
|
|
113
|
+
container = document.createElement('div');
|
|
114
|
+
document.body.appendChild(container);
|
|
115
|
+
});
|
|
116
|
+
afterEach(() => {
|
|
117
|
+
document.body.removeChild(container);
|
|
118
|
+
container = null;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// --- Test Cases ---
|
|
122
|
+
|
|
123
|
+
test('CreatePane renders correctly (snapshot test)', () => {
|
|
124
|
+
act(() => {
|
|
125
|
+
ReactDOM.render(<CreatePane />, container);
|
|
126
|
+
});
|
|
127
|
+
// Capture the snapshot of the rendered output.
|
|
128
|
+
expect(container.innerHTML).toMatchSnapshot();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('CreatePane loads child components', () => {
|
|
132
|
+
act(() => {
|
|
133
|
+
ReactDOM.render(<CreatePane />, container);
|
|
134
|
+
});
|
|
135
|
+
// Check that at least one of the mocked child components appears.
|
|
136
|
+
expect(container.textContent).toMatch(/Mock ModalSelectIncidentTypes/);
|
|
137
|
+
expect(container.textContent).toMatch(/Mock GetLocationsInService/);
|
|
138
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { stripesConnect } from '@folio/stripes/core';
|
|
4
|
+
import { IncidentContext } from '../../contexts/IncidentContext';
|
|
5
|
+
class CreateReport extends React.Component {
|
|
6
|
+
static contextType = IncidentContext;
|
|
7
|
+
|
|
8
|
+
static manifest = Object.freeze({
|
|
9
|
+
incident: {
|
|
10
|
+
type: 'okapi',
|
|
11
|
+
records: 'incidents',
|
|
12
|
+
POST: {
|
|
13
|
+
path: 'incidents',
|
|
14
|
+
// path: 'invalid_test_endpoint',
|
|
15
|
+
},
|
|
16
|
+
accumulate: true,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// console.log("manifest _resourceData:", JSON.stringify(_resourceData, null, 2));
|
|
21
|
+
|
|
22
|
+
static propTypes = {
|
|
23
|
+
data: PropTypes.object,
|
|
24
|
+
mutator: PropTypes.shape({
|
|
25
|
+
incident: PropTypes.shape({
|
|
26
|
+
POST: PropTypes.func.isRequired,
|
|
27
|
+
}).isRequired,
|
|
28
|
+
}).isRequired,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
componentDidUpdate(prevProps) {
|
|
32
|
+
if (this.props.data !== prevProps.data) {
|
|
33
|
+
this.createReport(this.props.data);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
createReport = (data) => {
|
|
38
|
+
// handle create report w/ attachments
|
|
39
|
+
if (data.attachments && data.attachments.length > 0) {
|
|
40
|
+
const attachmentsArray = data.attachments.map(att => ({ ...att }) );
|
|
41
|
+
const { attachments, ...preppedData } = data;
|
|
42
|
+
|
|
43
|
+
this.props.mutator.incident
|
|
44
|
+
.POST(preppedData)
|
|
45
|
+
.then((response) => {
|
|
46
|
+
const id = response.data.id;
|
|
47
|
+
this.context.setIdForMediaCreate(id);
|
|
48
|
+
this.context.setFormDataArrayForMediaCreate(attachmentsArray);
|
|
49
|
+
// setIsCreatingReport(false) invoked at CreateMedia
|
|
50
|
+
this.context.setMode('createMode');
|
|
51
|
+
// const defaultQuery = ''; // server response defaults to show most recent top 1000
|
|
52
|
+
// this.context.setQueryString(defaultQuery);
|
|
53
|
+
return response;
|
|
54
|
+
})
|
|
55
|
+
.catch((error) => {
|
|
56
|
+
console.error(
|
|
57
|
+
'@createReport - WITH Attachments - Error occurred:',
|
|
58
|
+
error
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// handle create report w/out attachments
|
|
63
|
+
} else if (data.attachments && data.attachments.length === 0) {
|
|
64
|
+
this.props.mutator.incident
|
|
65
|
+
.POST(data)
|
|
66
|
+
.then((response) => {
|
|
67
|
+
const id = response.data.id;
|
|
68
|
+
this.context.setIdForMediaCreate(null);
|
|
69
|
+
this.context.setFormDataArrayForMediaCreate(null);
|
|
70
|
+
this.context.setIncidentsList([]);
|
|
71
|
+
this.context.setMode('createMode');
|
|
72
|
+
// const defaultQuery = ''; // server response defaults to show most recent n
|
|
73
|
+
// this.context.setQueryString(defaultQuery);
|
|
74
|
+
this.context.setIsCreatingReport(false);
|
|
75
|
+
this.props.handleCloseNewOnSuccess(id);
|
|
76
|
+
return response;
|
|
77
|
+
})
|
|
78
|
+
.catch((error) => {
|
|
79
|
+
console.error(
|
|
80
|
+
'@createReport - NO Attachments - Error occurred:',
|
|
81
|
+
error
|
|
82
|
+
);
|
|
83
|
+
console.log('The error object: ', JSON.stringify(error, null, 2));
|
|
84
|
+
this.context.setModalErrorContent(
|
|
85
|
+
error.message || '@CreateReport - Unknown error'
|
|
86
|
+
);
|
|
87
|
+
this.context.openModalError();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
render() {
|
|
93
|
+
return <></>;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
CreateReport.contextType = IncidentContext;
|
|
98
|
+
CreateReport.propTypes = {
|
|
99
|
+
handleCloseNewOnSuccess: PropTypes.func.isRequired,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default stripesConnect(CreateReport, '@spokane-folio/security-incident');
|