@openmrs/esm-stock-management-app 3.0.1-pre.853 → 3.0.1-pre.855

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.
Files changed (108) hide show
  1. package/.husky/pre-commit +1 -4
  2. package/__mocks__/react-i18next.js +9 -8
  3. package/dist/10.js +1 -1
  4. package/dist/10.js.map +1 -1
  5. package/dist/119.js +1 -1
  6. package/dist/119.js.map +1 -1
  7. package/dist/14.js +1 -1
  8. package/dist/14.js.map +1 -1
  9. package/dist/172.js +1 -1
  10. package/dist/172.js.map +1 -1
  11. package/dist/20.js +1 -1
  12. package/dist/20.js.map +1 -1
  13. package/dist/290.js +1 -1
  14. package/dist/290.js.map +1 -1
  15. package/dist/467.js +1 -1
  16. package/dist/467.js.map +1 -1
  17. package/dist/574.js +1 -1
  18. package/dist/606.js +1 -1
  19. package/dist/606.js.map +1 -1
  20. package/dist/627.js +1 -0
  21. package/dist/627.js.map +1 -0
  22. package/dist/642.js +1 -1
  23. package/dist/642.js.map +1 -1
  24. package/dist/675.js +1 -1
  25. package/dist/675.js.map +1 -1
  26. package/dist/727.js +1 -1
  27. package/dist/727.js.map +1 -1
  28. package/dist/842.js +1 -1
  29. package/dist/842.js.map +1 -1
  30. package/dist/93.js +1 -1
  31. package/dist/93.js.map +1 -1
  32. package/dist/main.js +1 -1
  33. package/dist/main.js.map +1 -1
  34. package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +70 -70
  35. package/dist/routes.json +1 -1
  36. package/jest.config.js +3 -6
  37. package/package.json +1 -1
  38. package/src/core/components/table/table.component.tsx +2 -2
  39. package/src/index.ts +5 -5
  40. package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +3 -3
  41. package/src/stock-items/add-bulk-stock-item/{stock-items-bulk-import.modal.tsx → stock-items-bulk-import.component.tsx} +19 -20
  42. package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +1 -1
  43. package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.test.tsx +59 -59
  44. package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +6 -6
  45. package/src/stock-items/add-stock-item/add-stock-item.component.tsx +4 -6
  46. package/src/stock-items/add-stock-item/add-stock-item.scss +0 -5
  47. package/src/stock-items/add-stock-item/add-stock-item.test.tsx +43 -28
  48. package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete-modal.component.tsx +4 -3
  49. package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +10 -9
  50. package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +4 -4
  51. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +19 -27
  52. package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.scss +4 -4
  53. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +9 -15
  54. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +0 -1
  55. package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +1 -2
  56. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +16 -14
  57. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +3 -7
  58. package/src/stock-items/add-stock-item/transactions/printout/transactions-print-bincard-preview.modal.tsx +6 -14
  59. package/src/stock-items/add-stock-item/transactions/printout/transactions-print-stockcard-preview.modal.tsx +8 -14
  60. package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +2 -2
  61. package/src/stock-items/stock-item.utils.tsx +5 -3
  62. package/src/stock-items/stock-items-table.component.tsx +45 -47
  63. package/src/stock-items/stock-items-table.resource.ts +2 -2
  64. package/src/stock-items/stock-items-table.scss +1 -5
  65. package/src/stock-items/stock-items-table.test.tsx +65 -106
  66. package/src/stock-locations/location-admin-form.component.tsx +4 -5
  67. package/src/stock-locations/stock-locations-table.component.tsx +8 -10
  68. package/src/stock-lookups/stock-lookups.resource.ts +2 -3
  69. package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +2 -2
  70. package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx +11 -11
  71. package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.test.tsx +25 -115
  72. package/src/stock-operations/stock-operations-forms/input-components/qty-uim-selector.test.tsx +65 -107
  73. package/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx +9 -9
  74. package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.test.tsx +153 -35
  75. package/src/stock-operations/stock-operations-forms/input-components/user-selector.test.tsx +29 -82
  76. package/src/stock-operations/stock-operations-forms/step1.test.tsx +69 -204
  77. package/src/stock-operations/stock-operations-forms/step2.test.tsx +63 -140
  78. package/src/stock-operations/stock-operations-forms/step3.test.tsx +60 -79
  79. package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx +5 -6
  80. package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +11 -12
  81. package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.scss +0 -1
  82. package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx +12 -20
  83. package/src/stock-operations/stock-operations-forms/stock-operation-form.scss +0 -1
  84. package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stepper.scss +3 -1
  85. package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx +1 -2
  86. package/src/stock-reports/generate-report/create-stock-report.scss +2 -3
  87. package/src/stock-reports/generate-report/create-stock-report.workspace.tsx +25 -32
  88. package/src/stock-reports/report-list/stock-report-parameters.component.tsx +1 -1
  89. package/src/stock-reports/report-list/stock-report-status.component.tsx +1 -1
  90. package/src/stock-reports/report-list/stock-reports.component.tsx +25 -24
  91. package/src/stock-reports/report-list/stock-reports.scss +2 -10
  92. package/src/stock-sources/add-stock-sources/add-stock-sources.scss +4 -11
  93. package/src/stock-sources/add-stock-sources/add-stock-sources.test.tsx +36 -38
  94. package/src/stock-sources/add-stock-sources/add-stock-sources.workspace.tsx +30 -35
  95. package/src/stock-sources/delete-stock-modal.component.tsx +1 -2
  96. package/src/stock-sources/stock-sources-delete/stock-sources-delete.test.tsx +36 -27
  97. package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +21 -33
  98. package/src/stock-sources/stock-sources-items-table.component.tsx +17 -16
  99. package/src/stock-sources/stock-sources-items-table.resource.ts +6 -8
  100. package/src/stock-sources/stock-sources-items-table.test.tsx +37 -60
  101. package/src/stock-sources/stock-sources.scss +2 -6
  102. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +13 -5
  103. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.workspace.tsx +2 -2
  104. package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +1 -2
  105. package/translations/en.json +6 -5
  106. package/tsconfig.json +0 -4
  107. package/dist/33.js +0 -1
  108. package/dist/33.js.map +0 -1
@@ -1,20 +1,20 @@
1
- import React, { useCallback, useMemo, useState } from 'react';
2
1
  import { Button, Column, InlineLoading, RadioButton, RadioButtonGroup, Stack } from '@carbon/react';
3
2
  import { ArrowLeft, ArrowRight, Departure, ListChecked, Save, SendFilled } from '@carbon/react/icons';
3
+ import { restBaseUrl, showSnackbar } from '@openmrs/esm-framework';
4
+ import React, { useCallback, useMemo, useState } from 'react';
4
5
  import { useFormContext } from 'react-hook-form';
5
6
  import { useTranslation } from 'react-i18next';
6
- import { restBaseUrl, showSnackbar } from '@openmrs/esm-framework';
7
- import { createStockOperation, deleteStockOperationItem, updateStockOperation } from '../../stock-operations.resource';
8
7
  import { extractErrorMessagesFromResponse } from '../../../constants';
9
- import { handleMutate } from '../../../utils';
8
+ import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO';
9
+ import { type StockOperationItemDTO } from '../../../core/api/types/stockOperation/StockOperationItemDTO';
10
10
  import { OperationType, type StockOperationType } from '../../../core/api/types/stockOperation/StockOperationType';
11
11
  import { otherUser } from '../../../core/utils/utils';
12
+ import { handleMutate } from '../../../utils';
12
13
  import { showActionDialogButton } from '../../stock-operation.utils';
13
- import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO';
14
- import { type StockOperationItemDTO } from '../../../core/api/types/stockOperation/StockOperationItemDTO';
14
+ import { createStockOperation, deleteStockOperationItem, updateStockOperation } from '../../stock-operations.resource';
15
15
  import { type StockOperationItemDtoSchema } from '../../validation-schema';
16
- import styles from '../stock-operation-form.scss';
17
16
  import useOperationTypePermisions from '../hooks/useOperationTypePermisions';
17
+ import styles from '../stock-operation-form.scss';
18
18
 
19
19
  type StockOperationSubmissionFormStepProps = {
20
20
  onPrevious?: () => void;
@@ -23,7 +23,6 @@ type StockOperationSubmissionFormStepProps = {
23
23
  onNext?: () => void;
24
24
  dismissWorkspace?: () => void;
25
25
  };
26
-
27
26
  const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormStepProps> = ({
28
27
  onPrevious,
29
28
  stockOperationType,
@@ -153,12 +152,12 @@ const StockOperationSubmissionFormStep: React.FC<StockOperationSubmissionFormSte
153
152
  <RadioButtonGroup
154
153
  name="rbgApprovelRequired"
155
154
  legendText={t('doesThisTransactionRequireApproval', 'Does the transaction require approval ?')}
156
- onChange={(value) => handleRadioButtonChange(value === 'true')}
155
+ onChange={handleRadioButtonChange}
157
156
  readOnly={!editable}
158
- valueSelected={approvalRequired === true ? 'true' : approvalRequired === false ? 'false' : null}
157
+ valueSelected={approvalRequired === true ? true : approvalRequired === false ? false : null}
159
158
  >
160
- <RadioButton value="true" id="rbgApprovelRequired-true" labelText={t('yes', 'Yes')} />
161
- <RadioButton value="false" id="rbgApprovelRequired-false" labelText={t('no', 'No')} />
159
+ <RadioButton value={true} id="rbgApprovelRequired-true" labelText={t('yes', 'Yes')} />
160
+ <RadioButton value={false} id="rbgApprovelRequired-false" labelText={t('no', 'No')} />
162
161
  </RadioButtonGroup>
163
162
  </Column>
164
163
  {editable && (
@@ -16,7 +16,6 @@
16
16
  }
17
17
 
18
18
  .button {
19
- height: layout.$spacing-10;
20
19
  display: flex;
21
20
  align-content: flex-start;
22
21
  align-items: baseline;
@@ -1,5 +1,3 @@
1
- import React, { useMemo } from 'react';
2
- import classNames from 'classnames';
3
1
  import {
4
2
  Button,
5
3
  ButtonSet,
@@ -12,7 +10,8 @@ import {
12
10
  TextInput,
13
11
  } from '@carbon/react';
14
12
  import { zodResolver } from '@hookform/resolvers/zod';
15
- import { useConfig, useLayoutType } from '@openmrs/esm-framework';
13
+ import { DefaultWorkspaceProps, useConfig } from '@openmrs/esm-framework';
14
+ import React, { useMemo } from 'react';
16
15
  import { Controller, useForm } from 'react-hook-form';
17
16
  import { useTranslation } from 'react-i18next';
18
17
  import { type z } from 'zod';
@@ -21,14 +20,14 @@ import {
21
20
  operationFromString,
22
21
  type StockOperationType,
23
22
  } from '../../../core/api/types/stockOperation/StockOperationType';
24
- import { type BaseStockOperationItemFormData, getStockOperationItemFormSchema } from '../../validation-schema';
25
- import { type ConfigObject } from '../../../config-schema';
26
23
  import { useStockItem } from '../../../stock-items/stock-items.resource';
24
+ import { type BaseStockOperationItemFormData, getStockOperationItemFormSchema } from '../../validation-schema';
25
+ import useOperationTypePermisions from '../hooks/useOperationTypePermisions';
27
26
  import BatchNoSelector from '../input-components/batch-no-selector.component';
28
27
  import QtyUomSelector from '../input-components/quantity-uom-selector.component';
29
- import UniqueBatchNoEntryInput from '../input-components/unique-batch-no-entry-input.component';
30
- import useOperationTypePermisions from '../hooks/useOperationTypePermisions';
31
28
  import styles from './stock-item-form.scss';
29
+ import UniqueBatchNoEntryInput from '../input-components/unique-batch-no-entry-input.component';
30
+ import { type ConfigObject } from '../../../config-schema';
32
31
 
33
32
  export interface StockItemFormProps {
34
33
  stockOperationType: StockOperationType;
@@ -38,19 +37,18 @@ export interface StockItemFormProps {
38
37
  }
39
38
 
40
39
  const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stockOperationItem, onSave, onBack }) => {
41
- const isTablet = useLayoutType() === 'tablet';
42
40
  const operationType = useMemo(() => {
43
41
  return operationFromString(stockOperationType.operationType);
44
42
  }, [stockOperationType]);
45
- const formSchema = useMemo(() => {
43
+ const formschema = useMemo(() => {
46
44
  return getStockOperationItemFormSchema(operationType);
47
45
  }, [operationType]);
48
46
  const operationTypePermision = useOperationTypePermisions(stockOperationType);
49
47
  const { useItemCommonNameAsDisplay } = useConfig<ConfigObject>();
50
48
 
51
- const fields = formSchema.keyof().options;
52
- const form = useForm<z.infer<typeof formSchema>>({
53
- resolver: zodResolver(formSchema),
49
+ const fields = formschema.keyof().options;
50
+ const form = useForm<z.infer<typeof formschema>>({
51
+ resolver: zodResolver(formschema),
54
52
  defaultValues: stockOperationItem,
55
53
  mode: 'all',
56
54
  });
@@ -68,10 +66,9 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
68
66
  return `${item?.drugName || t('noDrugNameAvailable', 'No drug name available') + (commonName ?? '')}`;
69
67
  }, [item, useItemCommonNameAsDisplay, t]);
70
68
 
71
- const onSubmit = (data: z.infer<typeof formSchema>) => {
69
+ const onSubmit = (data: z.infer<typeof formschema>) => {
72
70
  onSave?.(data);
73
71
  };
74
-
75
72
  return (
76
73
  <Form onSubmit={form.handleSubmit(onSubmit)} className={styles.form}>
77
74
  <Stack gap={4} className={styles.grid}>
@@ -200,12 +197,7 @@ const StockItemForm: React.FC<StockItemFormProps> = ({ stockOperationType, stock
200
197
  )}
201
198
  </Stack>
202
199
 
203
- <ButtonSet
204
- className={classNames(styles.buttonSet, {
205
- [styles.tablet]: isTablet,
206
- [styles.desktop]: !isTablet,
207
- })}
208
- >
200
+ <ButtonSet className={styles.buttonSet}>
209
201
  <Button className={styles.button} kind="secondary" onClick={onBack}>
210
202
  {t('discard', 'Discard')}
211
203
  </Button>
@@ -17,7 +17,6 @@
17
17
  }
18
18
 
19
19
  .button {
20
- height: layout.$spacing-10;
21
20
  display: flex;
22
21
  align-content: flex-start;
23
22
  align-items: baseline;
@@ -5,7 +5,8 @@
5
5
  .layer {
6
6
  display: flex;
7
7
  flex-direction: row;
8
- padding: 0 layout.$spacing-03 0;
8
+ gap: layout.$spacing-05;
9
+ padding: layout.$spacing-03;
9
10
  height: 100%;
10
11
  }
11
12
 
@@ -39,4 +40,5 @@
39
40
 
40
41
  .content {
41
42
  flex: 1;
43
+ overflow: auto;
42
44
  }
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import { Layer } from '@carbon/react';
2
+ import React from 'react';
3
3
  import styles from './stepper.scss';
4
4
 
5
5
  export type Step = {
@@ -17,7 +17,6 @@ type StockOperationStepperProps = {
17
17
  selectedIndex?: number;
18
18
  onChange?: (index: number) => void;
19
19
  };
20
-
21
20
  const StockOperationStepper: React.FC<StockOperationStepperProps> = ({
22
21
  steps,
23
22
  hasContainer,
@@ -1,5 +1,5 @@
1
- @use '@carbon/layout';
2
- @use '@carbon/type';
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
3
  @use '@openmrs/esm-styleguide/src/vars' as *;
4
4
 
5
5
  .formContainer {
@@ -11,7 +11,6 @@
11
11
  }
12
12
 
13
13
  .button {
14
- height: layout.$spacing-10;
15
14
  display: flex;
16
15
  align-content: flex-start;
17
16
  align-items: baseline;
@@ -1,48 +1,48 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
- import classNames from 'classnames';
3
- import { useTranslation } from 'react-i18next';
4
2
  import {
5
3
  Button,
6
- ButtonSet,
7
- Checkbox,
4
+ InlineLoading,
8
5
  ComboBox,
9
- DatePicker,
10
6
  DatePickerInput,
11
- InlineLoading,
12
- NumberInput,
13
- RadioButton,
14
- RadioButtonGroup,
7
+ DatePicker,
15
8
  Select,
16
9
  SelectItem,
10
+ RadioButtonGroup,
11
+ RadioButton,
12
+ Form,
13
+ Checkbox,
14
+ NumberInput,
15
+ ButtonSet,
17
16
  } from '@carbon/react';
17
+ import styles from './create-stock-report.scss';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { useReportTypes } from '../stock-reports.resource';
20
+ import { DATE_PICKER_CONTROL_FORMAT, DATE_PICKER_FORMAT, formatForDatePicker, today } from '../../constants';
21
+ import { Controller, useForm } from 'react-hook-form';
22
+ import { zodResolver } from '@hookform/resolvers/zod';
23
+ import { type StockReportSchema, reportSchema } from '../report-validation-schema';
24
+ import { useConcept, useStockTagLocations } from '../../stock-lookups/stock-lookups.resource';
18
25
  import {
19
26
  type ConfigObject,
20
27
  type DefaultWorkspaceProps,
21
- getCoreTranslation,
22
28
  restBaseUrl,
23
29
  showSnackbar,
24
30
  useConfig,
25
- useLayoutType,
31
+ getCoreTranslation,
26
32
  } from '@openmrs/esm-framework';
27
- import { Controller, useForm } from 'react-hook-form';
28
- import { zodResolver } from '@hookform/resolvers/zod';
33
+ import { type Concept } from '../../core/api/types/concept/Concept';
34
+ import { createBatchJob } from '../../stock-batch/stock-batch.resource';
29
35
  import {
36
+ ReportParameter,
30
37
  getParamDefaultLimit,
31
38
  getReportEndDateLabel,
32
39
  getReportLimitLabel,
33
40
  getReportStartDateLabel,
34
- ReportParameter,
35
41
  } from '../ReportType';
36
- import { DATE_PICKER_CONTROL_FORMAT, DATE_PICKER_FORMAT, formatForDatePicker, today } from '../../constants';
37
- import { BatchJobTypeReport } from '../../core/api/types/BatchJob';
38
- import { createBatchJob } from '../../stock-batch/stock-batch.resource';
39
42
  import { formatDisplayDate } from '../../core/utils/datetimeUtils';
43
+ import { BatchJobTypeReport } from '../../core/api/types/BatchJob';
40
44
  import { handleMutate } from '../../utils';
41
- import { type Concept } from '../../core/api/types/concept/Concept';
42
- import { type StockReportSchema, reportSchema } from '../report-validation-schema';
43
- import { useConcept, useStockTagLocations } from '../../stock-lookups/stock-lookups.resource';
44
- import { useReportTypes } from '../stock-reports.resource';
45
- import styles from './create-stock-report.scss';
45
+ import { Save } from '@carbon/react/icons';
46
46
 
47
47
  type CreateReportProps = DefaultWorkspaceProps & {
48
48
  model?: ReportModel;
@@ -76,11 +76,9 @@ export interface ReportModel {
76
76
  mostLeastMovingName?: string;
77
77
  fullFillment?: string[];
78
78
  }
79
-
80
79
  const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) => {
81
80
  const { t } = useTranslation();
82
81
  const { stockItemCategoryUUID } = useConfig<ConfigObject>();
83
- const isTablet = useLayoutType() === 'tablet';
84
82
 
85
83
  const { reportTypes, isLoading } = useReportTypes();
86
84
  const { stockLocations } = useStockTagLocations();
@@ -642,17 +640,12 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
642
640
  )}
643
641
  </div>
644
642
 
645
- <ButtonSet
646
- className={classNames(styles.buttonSet, {
647
- [styles.tablet]: isTablet,
648
- [styles.desktop]: !isTablet,
649
- })}
650
- >
643
+ <ButtonSet className={styles.buttonSet}>
651
644
  <Button kind="secondary" onClick={closeWorkspace} className={styles.button}>
652
- {getCoreTranslation('cancel')}
645
+ {getCoreTranslation('cancel', 'Cancel')}
653
646
  </Button>
654
647
  <Button type="submit" className={styles.button} onClick={handleSave}>
655
- {getCoreTranslation('save')}
648
+ {getCoreTranslation('save', 'Save')}
656
649
  </Button>
657
650
  </ButtonSet>
658
651
  </div>
@@ -35,7 +35,7 @@ const StockReportParameters = (props: StockReportParametersProps) => {
35
35
  parseParametersToMap(props.model?.parameters, ['param.report']),
36
36
  );
37
37
  } catch (ex) {
38
- console.error(ex);
38
+ console.log(ex);
39
39
  }
40
40
 
41
41
  return <span>{parameterMap}</span>;
@@ -37,7 +37,7 @@ const StockReportStatus = (props: StockReportStatusProps) => {
37
37
  try {
38
38
  executionStateMap = displayParameterMap(props.model?.uuid, parseParametersToMap(props.model?.executionState));
39
39
  } catch (ex) {
40
- console.error(ex);
40
+ console.log(ex);
41
41
  }
42
42
  return (
43
43
  <div className={styles.statusContainer}>
@@ -1,39 +1,32 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import {
4
- Button,
5
4
  DataTable,
6
5
  DataTableSkeleton,
7
- InlineLoading,
6
+ TabPanel,
8
7
  Pagination,
9
8
  Table,
10
9
  TableBody,
11
10
  TableCell,
12
11
  TableContainer,
13
- TableExpandedRow,
14
- TableExpandHeader,
15
- TableExpandRow,
16
12
  TableHead,
17
13
  TableHeader,
18
14
  TableRow,
19
15
  TableToolbar,
20
- TableToolbarAction,
21
16
  TableToolbarContent,
22
- TableToolbarMenu,
23
17
  TableToolbarSearch,
24
- TabPanel,
25
18
  Tile,
19
+ Button,
20
+ InlineLoading,
21
+ TableToolbarMenu,
22
+ TableToolbarAction,
23
+ TableExpandHeader,
24
+ TableExpandRow,
25
+ TableExpandedRow,
26
26
  } from '@carbon/react';
27
- import {
28
- CheckmarkOutline,
29
- Copy,
30
- Download,
31
- IncompleteCancel,
32
- MisuseOutline,
33
- View,
34
- WarningAltFilled,
35
- } from '@carbon/react/icons';
36
27
  import { isDesktop, restBaseUrl, useSession } from '@openmrs/esm-framework';
28
+ import NewReportActionButton from './new-report-button.component';
29
+ import styles from './stock-reports.scss';
37
30
  import { useGetReports } from '../stock-reports.resource';
38
31
  import {
39
32
  URL_BATCH_JOB_ARTIFACT,
@@ -48,12 +41,19 @@ import {
48
41
  BatchJobStatusFailed,
49
42
  BatchJobStatusPending,
50
43
  } from '../../core/api/types/BatchJob';
44
+ import {
45
+ CheckmarkOutline,
46
+ Copy,
47
+ Download,
48
+ IncompleteCancel,
49
+ MisuseOutline,
50
+ View,
51
+ WarningAltFilled,
52
+ } from '@carbon/react/icons';
51
53
  import { handleMutate } from '../../utils';
52
54
  import { PrivilagedView } from '../../core/components/privilages-component/privilages.component';
53
- import NewReportActionButton from './new-report-button.component';
54
55
  import StockReportStatus from './stock-report-status.component';
55
56
  import StockReportParameters from './stock-report-parameters.component';
56
- import styles from './stock-reports.scss';
57
57
 
58
58
  const StockReports: React.FC = () => {
59
59
  const { t } = useTranslation();
@@ -202,9 +202,12 @@ const StockReports: React.FC = () => {
202
202
  }
203
203
 
204
204
  return (
205
- <div className={styles.container}>
205
+ <div className={styles.tableOverride}>
206
206
  <TabPanel>{t('ReportDescription', 'List of reports requested by users')}</TabPanel>
207
-
207
+ <div id="table-tool-bar">
208
+ <div></div>
209
+ <div className="right-filters"></div>
210
+ </div>
208
211
  <DataTable
209
212
  rows={tableRows}
210
213
  headers={tableHeaders}
@@ -222,9 +225,7 @@ const StockReports: React.FC = () => {
222
225
  <TableToolbarContent className={styles.toolbarContent}>
223
226
  <TableToolbarSearch persistent onChange={onInputChange} />
224
227
  <TableToolbarMenu>
225
- <TableToolbarAction className={styles.toolbarMenuAction} onClick={handleRefresh}>
226
- {t('refresh', 'Refresh')}
227
- </TableToolbarAction>
228
+ <TableToolbarAction onClick={handleRefresh}>Refresh</TableToolbarAction>
228
229
  </TableToolbarMenu>
229
230
  {canCreateReport && <NewReportActionButton />}
230
231
  </TableToolbarContent>
@@ -1,12 +1,8 @@
1
- @use '@carbon/colors';
1
+ @use '@carbon/styles/scss/colors';
2
+ @use '@carbon/styles/scss/type';
2
3
  @use '@carbon/layout';
3
- @use '@carbon/type';
4
4
  @use '@openmrs/esm-styleguide/src/vars' as *;
5
5
 
6
- .container {
7
- margin: layout.$spacing-05;
8
- }
9
-
10
6
  .content {
11
7
  @include type.type-style('heading-compact-02');
12
8
  color: $text-02;
@@ -82,7 +78,3 @@
82
78
  margin-right: 4px;
83
79
  }
84
80
  }
85
-
86
- .toolbarMenuAction {
87
- max-width: none;
88
- }
@@ -2,6 +2,10 @@
2
2
  @use '@carbon/type';
3
3
  @use '@openmrs/esm-styleguide/src/vars' as *;
4
4
 
5
+ .section {
6
+ margin: layout.$spacing-03;
7
+ }
8
+
5
9
  .sectionTitle {
6
10
  @include type.type-style('heading-compact-02');
7
11
  color: $text-02;
@@ -11,7 +15,6 @@
11
15
  .modalBody {
12
16
  padding-bottom: layout.$spacing-05;
13
17
  }
14
-
15
18
  .formContainer {
16
19
  display: flex;
17
20
  flex-direction: column;
@@ -21,7 +24,6 @@
21
24
  }
22
25
 
23
26
  .button {
24
- height: layout.$spacing-10;
25
27
  display: flex;
26
28
  align-content: flex-start;
27
29
  align-items: baseline;
@@ -37,12 +39,3 @@
37
39
  .body {
38
40
  padding: 1rem;
39
41
  }
40
-
41
- .tablet {
42
- padding: layout.$spacing-06 layout.$spacing-05;
43
- background-color: white;
44
- }
45
-
46
- .desktop {
47
- padding: 0;
48
- }
@@ -1,16 +1,24 @@
1
1
  import React from 'react';
2
- import userEvent from '@testing-library/user-event';
3
2
  import { render, screen } from '@testing-library/react';
4
- import { type FetchResponse, useConfig } from '@openmrs/esm-framework';
5
- import { type StockSource } from '../../core/api/types/stockOperation/StockSource';
6
- import { createOrUpdateStockSource } from '../stock-sources.resource';
3
+ import userEvent from '@testing-library/user-event';
4
+ import '@testing-library/jest-dom/extend-expect';
7
5
  import StockSourcesAddOrUpdate from './add-stock-sources.workspace';
6
+ import { createOrUpdateStockSource } from '../stock-sources.resource';
7
+ import { useConfig } from '@openmrs/esm-framework';
8
8
 
9
- const mockCreateOrUpdateStockSource = jest.mocked(createOrUpdateStockSource);
10
- const mockUseConfig = jest.mocked(useConfig);
9
+ import { type StockSource } from '../../core/api/types/stockOperation/StockSource';
11
10
 
12
- jest.mock('../stock-sources.resource', () => ({
13
- createOrUpdateStockSource: jest.fn(),
11
+ jest.mock('../stock-sources.resource');
12
+ jest.mock('@openmrs/esm-framework', () => ({
13
+ showSnackbar: jest.fn(),
14
+ useConfig: jest.fn(),
15
+ getCoreTranslation: jest.fn((key, defaultValue) => {
16
+ const translations: Record<string, string> = {
17
+ cancel: 'Cancel',
18
+ save: 'Save',
19
+ };
20
+ return translations[key] ?? defaultValue;
21
+ }),
14
22
  }));
15
23
 
16
24
  jest.mock('../../stock-lookups/stock-lookups.resource', () => ({
@@ -26,7 +34,7 @@ jest.mock('../../stock-lookups/stock-lookups.resource', () => ({
26
34
 
27
35
  describe('StockSourcesAddOrUpdate', () => {
28
36
  beforeEach(() => {
29
- mockUseConfig.mockReturnValue({ stockSourceTypeUUID: 'mock-uuid' });
37
+ (useConfig as jest.Mock).mockReturnValue({ stockSourceTypeUUID: 'mock-uuid' });
30
38
  });
31
39
 
32
40
  it('renders correctly without model prop', () => {
@@ -38,9 +46,9 @@ describe('StockSourcesAddOrUpdate', () => {
38
46
  promptBeforeClosing={jest.fn()}
39
47
  />,
40
48
  );
41
- expect(screen.getByLabelText(/full name/i)).toBeInTheDocument();
42
- expect(screen.getByLabelText(/acronym\/code/i)).toBeInTheDocument();
43
- expect(screen.getByLabelText(/source type/i)).toBeInTheDocument();
49
+ expect(screen.getByLabelText('Full Name')).toBeInTheDocument();
50
+ expect(screen.getByLabelText('Acronym/Code')).toBeInTheDocument();
51
+ expect(screen.getByLabelText('Source Type')).toBeInTheDocument();
44
52
  });
45
53
 
46
54
  it('renders correctly with model prop', () => {
@@ -102,9 +110,9 @@ describe('StockSourcesAddOrUpdate', () => {
102
110
  promptBeforeClosing={jest.fn()}
103
111
  />,
104
112
  );
105
- expect(screen.getByLabelText(/full name/i)).toHaveValue('Test Source');
106
- expect(screen.getByLabelText(/acronym\/code/i)).toHaveValue('TS');
107
- expect(screen.getByLabelText(/source type/i)).toHaveValue('type1');
113
+ expect(screen.getByLabelText('Full Name')).toHaveValue('Test Source');
114
+ expect(screen.getByLabelText('Acronym/Code')).toHaveValue('TS');
115
+ expect(screen.getByLabelText('Source Type')).toHaveValue('type1');
108
116
  });
109
117
 
110
118
  it('updates form fields correctly on user input', async () => {
@@ -118,21 +126,16 @@ describe('StockSourcesAddOrUpdate', () => {
118
126
  />,
119
127
  );
120
128
 
121
- await user.type(screen.getByLabelText(/full name/i), 'New Source');
122
- await user.type(screen.getByLabelText(/acronym\/code/i), 'NS');
129
+ await user.type(screen.getByLabelText('Full Name'), 'New Source');
130
+ await user.type(screen.getByLabelText('Acronym/Code'), 'NS');
123
131
 
124
- expect(screen.getByLabelText(/full name/i)).toHaveValue('New Source');
125
- expect(screen.getByLabelText(/acronym\/code/i)).toHaveValue('NS');
132
+ expect(screen.getByLabelText('Full Name')).toHaveValue('New Source');
133
+ expect(screen.getByLabelText('Acronym/Code')).toHaveValue('NS');
126
134
  });
127
135
 
128
136
  it('calls createOrUpdateStockSource with correct data on form submission', async () => {
129
137
  const user = userEvent.setup();
130
- mockCreateOrUpdateStockSource.mockResolvedValue({
131
- data: {},
132
- ok: true,
133
- status: 200,
134
- statusText: 'OK',
135
- } as unknown as FetchResponse);
138
+ (createOrUpdateStockSource as jest.Mock).mockResolvedValue({});
136
139
 
137
140
  render(
138
141
  <StockSourcesAddOrUpdate
@@ -143,20 +146,15 @@ describe('StockSourcesAddOrUpdate', () => {
143
146
  />,
144
147
  );
145
148
 
146
- await user.type(screen.getByLabelText(/full name/i), 'New Source');
147
- await user.type(screen.getByLabelText(/acronym\/code/i), 'NS');
148
- await user.selectOptions(screen.getByLabelText(/source type/i), 'type2');
149
+ await user.type(screen.getByLabelText('Full Name'), 'New Source');
150
+ await user.type(screen.getByLabelText('Acronym/Code'), 'NS');
151
+ await user.selectOptions(screen.getByLabelText('Source Type'), 'type2');
149
152
  await user.click(screen.getByText('Save'));
150
153
  });
151
154
 
152
155
  it('shows success message and closes overlay on successful submission', async () => {
153
156
  const user = userEvent.setup();
154
- mockCreateOrUpdateStockSource.mockResolvedValue({
155
- data: {},
156
- ok: true,
157
- status: 200,
158
- statusText: 'OK',
159
- } as unknown as FetchResponse);
157
+ (createOrUpdateStockSource as jest.Mock).mockResolvedValue({});
160
158
 
161
159
  render(
162
160
  <StockSourcesAddOrUpdate
@@ -167,12 +165,12 @@ describe('StockSourcesAddOrUpdate', () => {
167
165
  />,
168
166
  );
169
167
 
170
- await user.click(screen.getByText(/save/i));
168
+ await user.click(screen.getByText('Save'));
171
169
  });
172
170
 
173
171
  it('shows error message on failed submission', async () => {
174
172
  const user = userEvent.setup();
175
- mockCreateOrUpdateStockSource.mockRejectedValue(new Error('API Error'));
173
+ (createOrUpdateStockSource as jest.Mock).mockRejectedValue(new Error('API Error'));
176
174
 
177
175
  render(
178
176
  <StockSourcesAddOrUpdate
@@ -183,7 +181,7 @@ describe('StockSourcesAddOrUpdate', () => {
183
181
  />,
184
182
  );
185
183
 
186
- await user.click(screen.getByText(/save/i));
184
+ await user.click(screen.getByText('Save'));
187
185
  });
188
186
 
189
187
  it('closes overlay when cancel button is clicked', async () => {
@@ -197,6 +195,6 @@ describe('StockSourcesAddOrUpdate', () => {
197
195
  />,
198
196
  );
199
197
 
200
- await user.click(screen.getByText(/cancel/i));
198
+ await user.click(screen.getByText('Cancel'));
201
199
  });
202
200
  });