@openmrs/esm-stock-management-app 1.0.1-pre.777 → 1.0.1-pre.785
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/__mocks__/index.ts +1 -0
- package/__mocks__/operation-type.mock.ts +532 -0
- package/dist/155.js +1 -0
- package/dist/155.js.map +1 -0
- package/dist/172.js +1 -1
- package/dist/20.js +1 -1
- package/dist/290.js +1 -1
- package/dist/493.js +2 -0
- package/dist/493.js.map +1 -0
- package/dist/606.js +1 -1
- package/dist/627.js +1 -1
- package/dist/{400.js → 914.js} +1 -1
- package/dist/914.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +81 -57
- package/dist/openmrs-esm-stock-management-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/core/utils/utils.ts +29 -0
- package/src/index.ts +4 -0
- package/src/routes.json +9 -0
- package/src/stock-items/add-stock-item/transactions/printout/transactions-stockcard-printout.component.tsx +8 -12
- package/src/stock-items/add-stock-item/transactions/transactions.component.tsx +8 -12
- package/src/stock-items/stock-items.resource.ts +5 -5
- package/src/stock-lookups/stock-lookups.resource.ts +2 -2
- package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +41 -16
- package/src/stock-operations/{add-stock-operation/received-items.component.tsx → received-items.component.tsx} +1 -1
- package/src/stock-operations/stock-operation-reference.component.tsx +64 -0
- package/src/stock-operations/stock-operation-status/stock-operation-status-row.tsx +77 -0
- package/src/stock-operations/stock-operation-status/stock-operation-status.scss +32 -0
- package/src/stock-operations/stock-operation-status/stock-operation-status.tsx +45 -0
- package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +30 -29
- package/src/stock-operations/stock-operation.utils.tsx +16 -79
- package/src/stock-operations/stock-operations-dialog/stock-operations-issue-stock-button.component.tsx +27 -39
- package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx +51 -59
- package/src/stock-operations/{stock-item-selector/stock-item-selector.resource.tsx → stock-operations-forms/hooks/useFilterableStockItems.ts} +4 -4
- package/src/stock-operations/stock-operations-forms/hooks/useFilteredOperationTypesByRoles.ts +30 -0
- package/src/stock-operations/stock-operations-forms/hooks/useOperationTypePermisions.ts +29 -0
- package/src/stock-operations/stock-operations-forms/hooks/useParties.ts +73 -0
- package/src/stock-operations/{users-selector/users-selector.resource.tsx → stock-operations-forms/hooks/useSearchUser.ts} +9 -7
- package/src/stock-operations/{batch-no-selector/batch-no-selector.resource.tsx → stock-operations-forms/hooks/useStockItemBatchNumbers.ts} +3 -3
- package/src/stock-operations/stock-operations-forms/hooks/useStockOperationLinks.ts +20 -0
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx +72 -0
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.test.tsx +90 -0
- package/src/stock-operations/{add-stock-operation/stock-item-search/stock-item-search.scss → stock-operations-forms/input-components/input-components-styles.scss} +2 -2
- package/src/stock-operations/stock-operations-forms/input-components/qty-uim-selector.test.tsx +157 -0
- package/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx +53 -0
- package/src/stock-operations/stock-operations-forms/input-components/stock-item-search.component.tsx +56 -0
- package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.component.tsx +59 -0
- package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.test.tsx +216 -0
- package/src/stock-operations/stock-operations-forms/input-components/unique-batch-no-entry-input.component.tsx +59 -0
- package/src/stock-operations/stock-operations-forms/input-components/user-selector.test.tsx +110 -0
- package/src/stock-operations/stock-operations-forms/input-components/users-selector.component.tsx +111 -0
- package/src/stock-operations/stock-operations-forms/step1.test.tsx +303 -0
- package/src/stock-operations/stock-operations-forms/step2.test.tsx +250 -0
- package/src/stock-operations/stock-operations-forms/step3.test.tsx +223 -0
- package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx +241 -0
- package/src/stock-operations/stock-operations-forms/steps/quantity-uom-cell.component.tsx +33 -0
- package/src/stock-operations/stock-operations-forms/steps/stock-availability-cell.component.tsx +51 -0
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-item-batch-no-cell.component.tsx +40 -0
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-item-cell.component.tsx +38 -0
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-item-expiry-cell.component.tsx +41 -0
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx +281 -0
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.scc.scss +64 -0
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +236 -0
- package/src/stock-operations/stock-operations-forms/stock-issue-form-initializer-with-related-requisition-operation.component.tsx +55 -0
- package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.scss +41 -0
- package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx +197 -0
- package/src/stock-operations/stock-operations-forms/stock-operation-form-header.component.tsx +166 -0
- package/src/stock-operations/stock-operations-forms/stock-operation-form.component.tsx +200 -0
- package/src/stock-operations/stock-operations-forms/stock-operation-form.scss +111 -0
- package/src/stock-operations/stock-operations-forms/stock-operation-related-link.component.tsx +45 -0
- package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stepper.scss +41 -0
- package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx +52 -0
- package/src/stock-operations/stock-operations-forms/stock-operations-form-utils.ts +32 -0
- package/src/stock-operations/stock-operations-table.component.tsx +20 -56
- package/src/stock-operations/stock-operations.resource.ts +16 -13
- package/src/stock-operations/validation-schema.ts +72 -14
- package/dist/400.js.map +0 -1
- package/dist/766.js +0 -2
- package/dist/766.js.map +0 -1
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +0 -349
- package/src/stock-operations/add-stock-operation/add-stock-operation.resource.tsx +0 -27
- package/src/stock-operations/add-stock-operation/add-stock-operation.scss +0 -60
- package/src/stock-operations/add-stock-operation/add-stock-operation.test.tsx +0 -192
- package/src/stock-operations/add-stock-operation/add-stock-operation.utils.tsx +0 -152
- package/src/stock-operations/add-stock-operation/add-stock-utils.ts +0 -103
- package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +0 -439
- package/src/stock-operations/add-stock-operation/base-operation-details.scss +0 -30
- package/src/stock-operations/add-stock-operation/stock-item-search/stock-item-search.component.tsx +0 -70
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.component.tsx +0 -360
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.resource.tsx +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.scss +0 -12
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.test.tsx +0 -10
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.scss +0 -17
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.tsx +0 -254
- package/src/stock-operations/add-stock-operation/stock-operation-context/useStockOperationContext.tsx +0 -16
- package/src/stock-operations/add-stock-operation/stock-operation-reference.component.tsx +0 -39
- package/src/stock-operations/add-stock-operation/stock-operation-related-link.component.tsx +0 -38
- package/src/stock-operations/add-stock-operation/stock-operation-status.component.tsx +0 -170
- package/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx +0 -189
- package/src/stock-operations/add-stock-operation/stock-operation-submission.test.tsx +0 -138
- package/src/stock-operations/add-stock-operation/types.ts +0 -55
- package/src/stock-operations/add-stock-operation/validationSchema.ts +0 -54
- package/src/stock-operations/batch-no-selector/batch-no-selector.component.tsx +0 -114
- package/src/stock-operations/batch-no-selector/batch-no-selector.scss +0 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.test.tsx +0 -101
- package/src/stock-operations/party-selector/party-selector.component.tsx +0 -59
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.component.tsx +0 -65
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.resource.tsx +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.scss +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.test.tsx +0 -10
- package/src/stock-operations/stock-item-selector/stock-item-selector.component.tsx +0 -69
- package/src/stock-operations/stock-item-selector/stock-item-selector.scss +0 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.test.tsx +0 -10
- package/src/stock-operations/stock-operation-reason-selector/stock-operation-reason-selector.component.tsx +0 -62
- package/src/stock-operations/users-selector/users-selector.component.tsx +0 -75
- /package/dist/{766.js.LICENSE.txt → 493.js.LICENSE.txt} +0 -0
@@ -1,254 +0,0 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
2
|
-
import { StockOperationDTO } from '../../core/api/types/stockOperation/StockOperationDTO';
|
3
|
-
import { SaveStockOperation } from '../../stock-items/types';
|
4
|
-
import { StockOperationType } from '../../core/api/types/stockOperation/StockOperationType';
|
5
|
-
import { InitializeResult } from './types';
|
6
|
-
import {
|
7
|
-
Button,
|
8
|
-
DataTable,
|
9
|
-
InlineLoading,
|
10
|
-
Table,
|
11
|
-
TableBody,
|
12
|
-
TableContainer,
|
13
|
-
TableHead,
|
14
|
-
TableHeader,
|
15
|
-
TableRow,
|
16
|
-
} from '@carbon/react';
|
17
|
-
import { isDesktop } from '@openmrs/esm-framework';
|
18
|
-
import { StockOperationItemDTO } from '../../core/api/types/stockOperation/StockOperationItemDTO';
|
19
|
-
import { getStockOperationUniqueId } from '../stock-operation.utils';
|
20
|
-
import { useTranslation } from 'react-i18next';
|
21
|
-
import { FieldArrayWithId, FormProvider, useFieldArray, useForm } from 'react-hook-form';
|
22
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
23
|
-
import { useValidationSchema } from './validationSchema';
|
24
|
-
import StockItemsAdditionRow from './stock-items-addition-row.component';
|
25
|
-
import { ArrowRight } from '@carbon/react/icons';
|
26
|
-
import { errorAlert } from '../../core/utils/alert';
|
27
|
-
|
28
|
-
import styles from './stock-items-addition.component.scss';
|
29
|
-
import StockItemSearch from './stock-item-search/stock-item-search.component';
|
30
|
-
|
31
|
-
interface StockItemsAdditionProps {
|
32
|
-
isEditing?: boolean;
|
33
|
-
canEdit?: boolean;
|
34
|
-
model?: StockOperationDTO;
|
35
|
-
onSave?: SaveStockOperation;
|
36
|
-
operation: StockOperationType;
|
37
|
-
setup: InitializeResult;
|
38
|
-
}
|
39
|
-
|
40
|
-
const StockItemsAddition: React.FC<StockItemsAdditionProps> = ({
|
41
|
-
setup: {
|
42
|
-
hasQtyRequested: showQuantityRequested,
|
43
|
-
requiresBatchUuid,
|
44
|
-
requiresActualBatchInfo: requiresActualBatchInformation,
|
45
|
-
canCaptureQuantityPrice,
|
46
|
-
batchBalance,
|
47
|
-
batchNos,
|
48
|
-
canUpdateItemsBatchInformation: canUpdateBatchInformation,
|
49
|
-
itemUoM,
|
50
|
-
},
|
51
|
-
canEdit = true,
|
52
|
-
model,
|
53
|
-
onSave,
|
54
|
-
operation,
|
55
|
-
}) => {
|
56
|
-
const { t } = useTranslation();
|
57
|
-
const { operationType } = operation ?? {};
|
58
|
-
const validationSchema = useValidationSchema(operationType);
|
59
|
-
const handleSave = async (item: { stockItems: StockOperationItemDTO[] }) => {
|
60
|
-
if (item.stockItems.length == 0) {
|
61
|
-
errorAlert('No stock items', "You haven't added any stock items, tap the add button to add some.");
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
|
65
|
-
model.stockOperationItems = item?.stockItems;
|
66
|
-
await onSave?.(model);
|
67
|
-
};
|
68
|
-
|
69
|
-
const formMethods = useForm({
|
70
|
-
resolver: zodResolver(validationSchema),
|
71
|
-
defaultValues: {
|
72
|
-
stockItems: model?.stockOperationItems ?? [{ uuid: `new-item-1`, id: `new-item-1` }],
|
73
|
-
},
|
74
|
-
mode: 'onSubmit',
|
75
|
-
});
|
76
|
-
|
77
|
-
const {
|
78
|
-
handleSubmit,
|
79
|
-
control,
|
80
|
-
setValue,
|
81
|
-
formState: { errors },
|
82
|
-
} = formMethods;
|
83
|
-
|
84
|
-
const [isSaving] = useState(false);
|
85
|
-
|
86
|
-
const formFieldMethods = useFieldArray({
|
87
|
-
name: 'stockItems',
|
88
|
-
control,
|
89
|
-
});
|
90
|
-
const { fields, append, remove } = formFieldMethods;
|
91
|
-
const [selectedItems, setSelectedItems] = useState<
|
92
|
-
| FieldArrayWithId<{ stockItems: StockOperationItemDTO[] }, 'stockItems', 'id'>
|
93
|
-
| (() => FieldArrayWithId<{ stockItems: StockOperationItemDTO[] }, 'stockItems', 'id'>)
|
94
|
-
>();
|
95
|
-
|
96
|
-
useEffect(() => {
|
97
|
-
if (fields.length > 0) {
|
98
|
-
const lastItemIndex = fields.length - 1;
|
99
|
-
const item = fields[lastItemIndex];
|
100
|
-
setSelectedItems(item);
|
101
|
-
}
|
102
|
-
}, [fields]);
|
103
|
-
|
104
|
-
const headers = [
|
105
|
-
{
|
106
|
-
key: 'item',
|
107
|
-
header: t('item', 'Item'),
|
108
|
-
styles: { width: '40% !important' },
|
109
|
-
},
|
110
|
-
{
|
111
|
-
key: 'itemDetails',
|
112
|
-
header: t('itemDetails', 'Item Details'),
|
113
|
-
styles: { width: '20% !important' },
|
114
|
-
},
|
115
|
-
...(showQuantityRequested
|
116
|
-
? [
|
117
|
-
{
|
118
|
-
key: 'quantityrequested',
|
119
|
-
header: t('quantityRequested', 'Quantity Requested'),
|
120
|
-
},
|
121
|
-
]
|
122
|
-
: []),
|
123
|
-
...(requiresBatchUuid || requiresActualBatchInformation
|
124
|
-
? [
|
125
|
-
{
|
126
|
-
key: 'batch',
|
127
|
-
header: t('batchNo', 'Batch No'),
|
128
|
-
styles: { width: '15% !important' },
|
129
|
-
},
|
130
|
-
]
|
131
|
-
: []),
|
132
|
-
...(requiresActualBatchInformation
|
133
|
-
? [
|
134
|
-
{
|
135
|
-
key: 'expiry',
|
136
|
-
header: t('expiry', 'Expiry'),
|
137
|
-
},
|
138
|
-
]
|
139
|
-
: []),
|
140
|
-
...(requiresBatchUuid
|
141
|
-
? [
|
142
|
-
{
|
143
|
-
key: 'expiry',
|
144
|
-
header: t('expiry', 'Expiry'),
|
145
|
-
},
|
146
|
-
]
|
147
|
-
: []),
|
148
|
-
|
149
|
-
{
|
150
|
-
key: 'quantity',
|
151
|
-
header: showQuantityRequested ? t('qtyIssued', 'Qty Issued') : t('qty', 'Qty'),
|
152
|
-
},
|
153
|
-
{
|
154
|
-
key: 'quantityuom',
|
155
|
-
header: t('quantityUom', 'Qty UoM'),
|
156
|
-
},
|
157
|
-
...(canCaptureQuantityPrice
|
158
|
-
? [
|
159
|
-
{
|
160
|
-
key: 'purchaseprice',
|
161
|
-
header: t('purchasePrice', 'Purchase Price'),
|
162
|
-
},
|
163
|
-
]
|
164
|
-
: []),
|
165
|
-
];
|
166
|
-
|
167
|
-
const addNewItem = () => {
|
168
|
-
const itemId = `new-item-${getStockOperationUniqueId()}`;
|
169
|
-
append({
|
170
|
-
uuid: itemId,
|
171
|
-
id: itemId,
|
172
|
-
stockItemUuid: null,
|
173
|
-
stockItemName: '',
|
174
|
-
});
|
175
|
-
};
|
176
|
-
|
177
|
-
return (
|
178
|
-
<FormProvider {...formMethods}>
|
179
|
-
<div style={{ margin: '10px' }}>
|
180
|
-
<div className={styles.tableContainer}>
|
181
|
-
<StockItemSearch {...formFieldMethods} />
|
182
|
-
<DataTable
|
183
|
-
rows={model?.stockOperationItems ?? [{ uuid: `new-item-1`, id: `new-item-1` }]}
|
184
|
-
headers={headers}
|
185
|
-
isSortable={false}
|
186
|
-
useZebraStyles={true}
|
187
|
-
className={styles.dataTable}
|
188
|
-
render={({ headers, getHeaderProps, getTableProps }) => (
|
189
|
-
<TableContainer>
|
190
|
-
<Table {...getTableProps()}>
|
191
|
-
<TableHead>
|
192
|
-
<TableRow>
|
193
|
-
{headers.map((header: any) => (
|
194
|
-
<TableHeader
|
195
|
-
{...getHeaderProps({
|
196
|
-
header,
|
197
|
-
isSortable: false,
|
198
|
-
})}
|
199
|
-
className={isDesktop ? styles.desktopHeader : styles.tabletHeader}
|
200
|
-
style={header?.styles}
|
201
|
-
key={`${header.key}`}
|
202
|
-
>
|
203
|
-
{header.header?.content ?? header?.header}
|
204
|
-
</TableHeader>
|
205
|
-
))}
|
206
|
-
{canEdit && (
|
207
|
-
<TableHeader className={styles.tableHeader}>
|
208
|
-
<div className={styles.TableBody}>
|
209
|
-
<Button
|
210
|
-
name="save"
|
211
|
-
type="button"
|
212
|
-
className="submitButton"
|
213
|
-
onClick={() => handleSubmit(handleSave)()}
|
214
|
-
kind="primary"
|
215
|
-
renderIcon={ArrowRight}
|
216
|
-
>
|
217
|
-
{isSaving ? <InlineLoading /> : t('next', 'Next')}
|
218
|
-
</Button>
|
219
|
-
</div>
|
220
|
-
</TableHeader>
|
221
|
-
)}
|
222
|
-
</TableRow>
|
223
|
-
</TableHead>
|
224
|
-
<TableBody>
|
225
|
-
<StockItemsAdditionRow
|
226
|
-
rows={model?.stockOperationItems ?? [{ uuid: `new-item-1`, id: `new-item-1` }]}
|
227
|
-
batchBalance={batchBalance}
|
228
|
-
batchNos={batchNos}
|
229
|
-
control={control}
|
230
|
-
setValue={setValue}
|
231
|
-
errors={errors}
|
232
|
-
remove={remove}
|
233
|
-
append={append}
|
234
|
-
canEdit={canEdit}
|
235
|
-
showQuantityRequested={showQuantityRequested}
|
236
|
-
requiresActualBatchInformation={requiresActualBatchInformation}
|
237
|
-
requiresBatchUuid={requiresBatchUuid}
|
238
|
-
canUpdateBatchInformation={canUpdateBatchInformation}
|
239
|
-
canCapturePurchasePrice={canCaptureQuantityPrice}
|
240
|
-
itemUoM={itemUoM}
|
241
|
-
fields={fields}
|
242
|
-
/>{' '}
|
243
|
-
</TableBody>
|
244
|
-
</Table>
|
245
|
-
</TableContainer>
|
246
|
-
)}
|
247
|
-
></DataTable>
|
248
|
-
</div>
|
249
|
-
</div>
|
250
|
-
</FormProvider>
|
251
|
-
);
|
252
|
-
};
|
253
|
-
|
254
|
-
export default StockItemsAddition;
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import React, { createContext, useContext, useState } from 'react';
|
2
|
-
|
3
|
-
type StockOperationShape = {
|
4
|
-
formContext: Record<string, unknown>;
|
5
|
-
setFormContext: (formValue) => void;
|
6
|
-
};
|
7
|
-
|
8
|
-
const StockOperationContext = createContext<StockOperationShape>(null);
|
9
|
-
|
10
|
-
export const useStockOperationContext = () => useContext(StockOperationContext);
|
11
|
-
|
12
|
-
export const StockOperation: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
13
|
-
const [formContext, setFormContext] = useState<StockOperationShape>(null);
|
14
|
-
const value = { formContext, setFormContext };
|
15
|
-
return <StockOperationContext.Provider value={value}>{children}</StockOperationContext.Provider>;
|
16
|
-
};
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { StockOperationDTO } from '../../core/api/types/stockOperation/StockOperationDTO';
|
3
|
-
import { launchAddOrEditDialog } from '../stock-operation.utils';
|
4
|
-
import { useTranslation } from 'react-i18next';
|
5
|
-
import { getStockOperation } from '../stock-operations.resource';
|
6
|
-
import { useStockOperationTypes } from '../../stock-lookups/stock-lookups.resource';
|
7
|
-
|
8
|
-
interface StockOperationReferenceProps {
|
9
|
-
operationUuid: string;
|
10
|
-
operationNumber: string;
|
11
|
-
}
|
12
|
-
|
13
|
-
const StockOperationReference = (props: StockOperationReferenceProps) => {
|
14
|
-
const { t } = useTranslation();
|
15
|
-
const { types } = useStockOperationTypes();
|
16
|
-
|
17
|
-
let model: StockOperationDTO;
|
18
|
-
if (props?.operationUuid) {
|
19
|
-
getStockOperation(props?.operationUuid).then((resp) => {
|
20
|
-
model = resp?.data;
|
21
|
-
});
|
22
|
-
}
|
23
|
-
|
24
|
-
const handleEdit = () => {
|
25
|
-
const operation = types.results?.find((op) => op?.uuid === model?.operationTypeUuid);
|
26
|
-
|
27
|
-
if (!operation) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
launchAddOrEditDialog(t, model, true, operation, types?.results, false);
|
31
|
-
};
|
32
|
-
return (
|
33
|
-
<a onClick={handleEdit} style={{ cursor: 'pointer' }}>
|
34
|
-
{props?.operationNumber}
|
35
|
-
</a>
|
36
|
-
);
|
37
|
-
};
|
38
|
-
|
39
|
-
export default StockOperationReference;
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { useTranslation } from 'react-i18next';
|
3
|
-
import { StockOperationDTO } from '../../core/api/types/stockOperation/StockOperationDTO';
|
4
|
-
import { StockOperationType } from '../../core/api/types/stockOperation/StockOperationType';
|
5
|
-
import { launchAddOrEditDialog } from '../stock-operation.utils';
|
6
|
-
import { getStockOperation } from '../stock-operations.resource';
|
7
|
-
|
8
|
-
interface StockOperationRelatedLinkProps {
|
9
|
-
operationTypes: StockOperationType[];
|
10
|
-
operationUuid: string;
|
11
|
-
operationNumber: string;
|
12
|
-
}
|
13
|
-
|
14
|
-
const StockOperationRelatedLink = (props: StockOperationRelatedLinkProps) => {
|
15
|
-
const { t } = useTranslation();
|
16
|
-
const operationTypes = props?.operationTypes;
|
17
|
-
let model: StockOperationDTO;
|
18
|
-
|
19
|
-
getStockOperation(props?.operationUuid).then((resp) => {
|
20
|
-
model = resp.data;
|
21
|
-
});
|
22
|
-
|
23
|
-
const handleEdit = () => {
|
24
|
-
const operation = operationTypes?.find((op) => op?.uuid === model?.operationTypeUuid);
|
25
|
-
|
26
|
-
if (!operation) {
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
launchAddOrEditDialog(t, model, true, operation, operationTypes, false);
|
30
|
-
};
|
31
|
-
return (
|
32
|
-
<span onClick={handleEdit} style={{ cursor: 'pointer', textDecoration: 'underline' }}>
|
33
|
-
{props?.operationNumber}
|
34
|
-
</span>
|
35
|
-
);
|
36
|
-
};
|
37
|
-
|
38
|
-
export default StockOperationRelatedLink;
|
@@ -1,170 +0,0 @@
|
|
1
|
-
import { useTranslation } from 'react-i18next';
|
2
|
-
import { StockOperationDTO } from '../../core/api/types/stockOperation/StockOperationDTO';
|
3
|
-
import React from 'react';
|
4
|
-
import { formatDate, parseDate } from '@openmrs/esm-framework';
|
5
|
-
import styles from '../stock-operations-table.scss';
|
6
|
-
|
7
|
-
interface StockOperationStatusProps {
|
8
|
-
model: StockOperationDTO;
|
9
|
-
}
|
10
|
-
|
11
|
-
const StockOperationStatus: React.FC<StockOperationStatusProps> = (props) => {
|
12
|
-
const { t } = useTranslation();
|
13
|
-
return (
|
14
|
-
<>
|
15
|
-
<div className={styles.statusContainer}>
|
16
|
-
{props.model?.dateCreated && (
|
17
|
-
<div>
|
18
|
-
<span className={styles.textHeading}>{t('started', 'Started')}:</span>
|
19
|
-
<div className={styles.statusDescriptions}>
|
20
|
-
<span className={styles.text}>
|
21
|
-
{formatDate(parseDate(props.model?.dateCreated.toString()), {
|
22
|
-
time: true,
|
23
|
-
mode: 'standard',
|
24
|
-
})}
|
25
|
-
</span>
|
26
|
-
|
27
|
-
<span className={styles.text}>{t('by', 'By')}</span>
|
28
|
-
|
29
|
-
<span className={styles.text}>
|
30
|
-
{props.model?.creatorFamilyName}
|
31
|
-
{props.model?.creatorGivenName}
|
32
|
-
</span>
|
33
|
-
</div>
|
34
|
-
</div>
|
35
|
-
)}
|
36
|
-
|
37
|
-
{props.model.submittedDate && (
|
38
|
-
<div>
|
39
|
-
<span className={styles.textHeading}>{t('submitted', 'Submitted')}:</span>
|
40
|
-
<div className={styles.statusDescriptions}>
|
41
|
-
<span className={styles.text}>
|
42
|
-
{formatDate(parseDate(props.model?.submittedDate.toString()), {
|
43
|
-
time: true,
|
44
|
-
mode: 'standard',
|
45
|
-
})}
|
46
|
-
</span>
|
47
|
-
|
48
|
-
<span className={styles.text}>{t('by', 'By')}</span>
|
49
|
-
|
50
|
-
<span className={styles.text}>
|
51
|
-
{props.model?.submittedByFamilyName}
|
52
|
-
{props.model?.submittedByGivenName}
|
53
|
-
</span>
|
54
|
-
</div>
|
55
|
-
</div>
|
56
|
-
)}
|
57
|
-
|
58
|
-
{props.model?.dispatchedDate && (
|
59
|
-
<div>
|
60
|
-
<span className={styles.textHeading}>{t('dispatched', 'Dispatched')}:</span>
|
61
|
-
<div className={styles.statusDescriptions}>
|
62
|
-
<span className={styles.text}>
|
63
|
-
{formatDate(parseDate(props.model?.dispatchedDate.toString()), {
|
64
|
-
time: true,
|
65
|
-
mode: 'standard',
|
66
|
-
})}
|
67
|
-
</span>
|
68
|
-
|
69
|
-
<span className={styles.text}>{t('by', 'By')}</span>
|
70
|
-
|
71
|
-
<span className={styles.text}>
|
72
|
-
{props.model?.dispatchedByFamilyName}
|
73
|
-
{props.model?.dispatchedByGivenName}
|
74
|
-
</span>
|
75
|
-
</div>
|
76
|
-
</div>
|
77
|
-
)}
|
78
|
-
|
79
|
-
{props.model?.returnedDate && (
|
80
|
-
<div>
|
81
|
-
<span className={styles.textHeading}>{t('returned', 'Returned')}:</span>
|
82
|
-
<div className={styles.statusDescriptions}>
|
83
|
-
<span className={styles.text}>
|
84
|
-
{formatDate(parseDate(props.model?.returnedDate.toString()), {
|
85
|
-
time: true,
|
86
|
-
mode: 'standard',
|
87
|
-
})}
|
88
|
-
</span>
|
89
|
-
|
90
|
-
<span className={styles.text}>{t('by', 'By')}</span>
|
91
|
-
|
92
|
-
<span className={styles.text}>
|
93
|
-
{props.model?.returnedByFamilyName}
|
94
|
-
{props.model?.returnedByGivenName}
|
95
|
-
</span>
|
96
|
-
<span className={styles.text}>{props.model?.returnReason}</span>
|
97
|
-
</div>
|
98
|
-
</div>
|
99
|
-
)}
|
100
|
-
|
101
|
-
{props.model?.completedDate && (
|
102
|
-
<div>
|
103
|
-
<span className={styles.textHeading}>{t('completed', 'Completed')}:</span>
|
104
|
-
<div className={styles.statusDescriptions}>
|
105
|
-
<span className={styles.text}>
|
106
|
-
{formatDate(parseDate(props.model?.completedDate.toString()), {
|
107
|
-
time: true,
|
108
|
-
mode: 'standard',
|
109
|
-
})}
|
110
|
-
</span>
|
111
|
-
|
112
|
-
<span className={styles.text}>{t('by', 'By')}</span>
|
113
|
-
|
114
|
-
<span className={styles.text}>
|
115
|
-
{props.model?.completedByFamilyName}
|
116
|
-
{props.model?.completedByGivenName}
|
117
|
-
</span>
|
118
|
-
</div>
|
119
|
-
</div>
|
120
|
-
)}
|
121
|
-
|
122
|
-
{props.model?.status === 'CANCELLED' && (
|
123
|
-
<div>
|
124
|
-
<span className={styles.textHeading}>{t('cancelled', 'Cancelled')}:</span>
|
125
|
-
<div className={styles.statusDescriptions}>
|
126
|
-
<span className={styles.text}>
|
127
|
-
{formatDate(parseDate(props.model?.cancelledDate.toString()), {
|
128
|
-
time: true,
|
129
|
-
mode: 'standard',
|
130
|
-
})}
|
131
|
-
</span>
|
132
|
-
|
133
|
-
<span className={styles.text}>{t('by', 'By')}</span>
|
134
|
-
|
135
|
-
<span className={styles.text}>
|
136
|
-
{props.model?.cancelledByFamilyName}
|
137
|
-
{props.model?.cancelledByGivenName}
|
138
|
-
<span className={styles.text}>{props.model?.cancelReason}</span>
|
139
|
-
</span>
|
140
|
-
</div>
|
141
|
-
</div>
|
142
|
-
)}
|
143
|
-
|
144
|
-
{props.model?.status === 'REJECTED' && (
|
145
|
-
<div>
|
146
|
-
<span className={styles.textHeading}>{t('rejected', 'Rejected')}:</span>
|
147
|
-
<div className={styles.statusDescriptions}>
|
148
|
-
<span className={styles.text}>
|
149
|
-
{formatDate(parseDate(props.model?.rejectedDate.toString()), {
|
150
|
-
time: true,
|
151
|
-
mode: 'standard',
|
152
|
-
})}
|
153
|
-
</span>
|
154
|
-
|
155
|
-
<span className={styles.text}>{t('by', 'By')}</span>
|
156
|
-
|
157
|
-
<span className={styles.text}>
|
158
|
-
{props.model?.rejectedByFamilyName}
|
159
|
-
{props.model?.rejectedByGivenName}
|
160
|
-
<span>{props.model?.rejectionReason}</span>
|
161
|
-
</span>
|
162
|
-
</div>
|
163
|
-
</div>
|
164
|
-
)}
|
165
|
-
</div>
|
166
|
-
</>
|
167
|
-
);
|
168
|
-
};
|
169
|
-
|
170
|
-
export default StockOperationStatus;
|