@openmrs/esm-stock-management-app 3.1.1-pre.1179 → 3.1.1-pre.1186

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 (118) hide show
  1. package/.husky/pre-commit +0 -5
  2. package/.husky/pre-push +0 -3
  3. package/dist/130.js +1 -1
  4. package/dist/130.js.map +1 -1
  5. package/dist/2177.js +1 -1
  6. package/dist/2177.js.map +1 -1
  7. package/dist/3066.js +2 -0
  8. package/dist/3066.js.map +1 -0
  9. package/dist/3220.js +1 -1
  10. package/dist/3220.js.map +1 -1
  11. package/dist/4300.js +1 -1
  12. package/dist/4732.js +1 -1
  13. package/dist/4732.js.map +1 -1
  14. package/dist/5125.js +1 -1
  15. package/dist/5125.js.map +1 -1
  16. package/dist/5333.js +1 -1
  17. package/dist/5333.js.map +1 -1
  18. package/dist/5609.js +1 -1
  19. package/dist/5609.js.map +1 -1
  20. package/dist/6184.js +1 -1
  21. package/dist/6184.js.map +1 -1
  22. package/dist/6757.js +1 -1
  23. package/dist/6757.js.map +1 -1
  24. package/dist/8161.js +1 -1
  25. package/dist/8161.js.map +1 -1
  26. package/dist/9186.js +1 -1
  27. package/dist/9186.js.map +1 -1
  28. package/dist/main.js +1 -1
  29. package/dist/main.js.map +1 -1
  30. package/dist/openmrs-esm-stock-management-app.js +1 -1
  31. package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +64 -64
  32. package/dist/routes.json +1 -1
  33. package/package.json +1 -1
  34. package/src/constants.ts +2 -3
  35. package/src/core/components/carbon/controlled-combo-box.component.tsx +12 -9
  36. package/src/core/components/carbon/controlled-radio-button-group.component.tsx +21 -16
  37. package/src/core/components/table/table.component.tsx +26 -17
  38. package/src/core/components/table/table.scss +4 -0
  39. package/src/core/components/table/types.ts +12 -0
  40. package/src/core/components/tabs/vertical-tabs.component.tsx +2 -6
  41. package/src/declarations.d.ts +0 -3
  42. package/src/stock-home/stock-home-inventory-card.component.tsx +2 -2
  43. package/src/stock-items/add-stock-item/add-stock-item.component.tsx +1 -1
  44. package/src/stock-items/add-stock-item/batch-information/batch-information-locations/batch-information-locations-filter.component.tsx +0 -3
  45. package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +4 -4
  46. package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +2 -5
  47. package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +4 -8
  48. package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete.modal.tsx +2 -2
  49. package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +32 -18
  50. package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +2 -5
  51. package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +0 -3
  52. package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +2 -5
  53. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +10 -10
  54. package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.component.tsx +36 -27
  55. package/src/stock-items/add-stock-item/stock-item-references/stock-references-selector.component.tsx +2 -5
  56. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +16 -16
  57. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +10 -9
  58. package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.component.tsx +8 -3
  59. package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +2 -2
  60. package/src/stock-items/add-stock-item/transactions/printout/printable-bincard-transaction-header.component.tsx +5 -5
  61. package/src/stock-items/add-stock-item/transactions/printout/printable-stockcard-transaction-header.component.tsx +3 -3
  62. package/src/stock-items/add-stock-item/transactions/printout/transactions-print-action.component.tsx +2 -5
  63. package/src/stock-items/add-stock-item/transactions/printout/transactions-print-bincard-preview.modal.tsx +1 -1
  64. package/src/stock-items/add-stock-item/transactions/transaction-filters/transaction-locations-filter.component.tsx +0 -3
  65. package/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx +6 -4
  66. package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +1 -1
  67. package/src/stock-items/stock-items-table.component.tsx +21 -15
  68. package/src/stock-items/stock-items-table.resource.ts +1 -1
  69. package/src/stock-items/stock-items.resource.ts +1 -2
  70. package/src/stock-locations/add-locations-form.workspace.tsx +9 -11
  71. package/src/stock-locations/location-admin-form.component.tsx +9 -4
  72. package/src/stock-locations/stock-locations-table.component.tsx +3 -3
  73. package/src/stock-lookups/stock-lookups.resource.ts +2 -2
  74. package/src/stock-management-admin-card-link.component.tsx +1 -1
  75. package/src/stock-operations/add-stock-operation/stock-operations-expanded-row/stock-items-table.tsx +12 -8
  76. package/src/stock-operations/add-stock-operation/stock-operations-expanded-row/stock-operation-expanded-row.component.tsx +4 -4
  77. package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +6 -7
  78. package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.component.tsx +7 -3
  79. package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.component.tsx +8 -4
  80. package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.component.tsx +16 -14
  81. package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +4 -4
  82. package/src/stock-operations/stock-operations-filters.component.tsx +4 -2
  83. package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx +2 -2
  84. package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.test.tsx +1 -1
  85. package/src/stock-operations/stock-operations-forms/input-components/qty-uim-selector.test.tsx +1 -1
  86. package/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx +3 -3
  87. package/src/stock-operations/stock-operations-forms/input-components/stock-item-search.component.tsx +3 -4
  88. package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.component.tsx +3 -3
  89. package/src/stock-operations/stock-operations-forms/input-components/users-selector.component.tsx +6 -6
  90. package/src/stock-operations/stock-operations-forms/step2.test.tsx +1 -5
  91. package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx +15 -16
  92. package/src/stock-operations/stock-operations-forms/steps/quantity-uom-cell.component.tsx +1 -1
  93. package/src/stock-operations/stock-operations-forms/steps/received-items.component.tsx +2 -2
  94. package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx +24 -21
  95. package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +4 -4
  96. package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx +60 -53
  97. package/src/stock-operations/stock-operations-forms/stock-operation-form.component.tsx +17 -12
  98. package/src/stock-operations/stock-operations-modal/stock-operations-completed-dispatch-button.component.tsx +1 -1
  99. package/src/stock-operations/stock-operations-modal/stock-operations-issue-stock-button.component.tsx +1 -1
  100. package/src/stock-operations/stock-operations-modal/stock-operations-print-button.component.tsx +6 -2
  101. package/src/stock-operations/stock-operations-modal/stock-operations-reject-button.component.tsx +4 -5
  102. package/src/stock-operations/stock-operations-modal/stock-operations.modal.tsx +4 -2
  103. package/src/stock-operations/stock-operations-table.component.tsx +16 -12
  104. package/src/stock-operations/stock-operations-table.resource.ts +1 -0
  105. package/src/stock-reports/generate-report/create-stock-report.workspace.tsx +31 -35
  106. package/src/stock-reports/report-list/stock-reports.component.tsx +5 -9
  107. package/src/stock-reports/stock-reports.resource.ts +1 -1
  108. package/src/stock-sources/add-stock-sources/add-stock-sources.workspace.tsx +6 -6
  109. package/src/stock-sources/stock-sources-items-table.component.tsx +14 -10
  110. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.workspace.tsx +52 -53
  111. package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +1 -1
  112. package/src/stock-user-role-scopes/delete-stock-user-scope.modal.tsx +4 -1
  113. package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +8 -12
  114. package/translations/en.json +105 -71
  115. package/dist/2474.js +0 -2
  116. package/dist/2474.js.map +0 -1
  117. package/src/core/components/carbon/controlled-dropdown.component.tsx +0 -37
  118. /package/dist/{2474.js.LICENSE.txt → 3066.js.LICENSE.txt} +0 -0
@@ -8,14 +8,14 @@ import {
8
8
  ComboBox,
9
9
  DatePicker,
10
10
  DatePickerInput,
11
+ Form,
12
+ FormGroup,
11
13
  InlineLoading,
12
14
  NumberInput,
13
15
  RadioButton,
14
16
  RadioButtonGroup,
15
17
  Select,
16
18
  SelectItem,
17
- Form,
18
- FormGroup,
19
19
  Stack,
20
20
  } from '@carbon/react';
21
21
  import {
@@ -112,7 +112,9 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
112
112
  useEffect(() => {
113
113
  let hasResetParameters = false;
114
114
  if (selectedReportName) {
115
- const reportType = (reportTypes as any)?.find((p) => p.name === selectedReportName);
115
+ const reportType = Array.isArray(reportTypes)
116
+ ? reportTypes.find((p) => p.name === selectedReportName)
117
+ : undefined;
116
118
  if (reportType) {
117
119
  setDisplayDate(reportType.parameters?.some((p) => p === ReportParameter.Date));
118
120
  setDisplayStartDate(reportType.parameters?.some((p) => p === ReportParameter.StartDate));
@@ -159,7 +161,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
159
161
  display: 'All Categories',
160
162
  name: 'All Categories',
161
163
  uuid: '',
162
- } as any as Concept,
164
+ } as unknown as Concept,
163
165
  ...((items && items?.answers?.length > 0 ? items?.answers : items?.setMembers) ?? []),
164
166
  ];
165
167
  }, [items]);
@@ -178,9 +180,9 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
178
180
  }
179
181
 
180
182
  const handleSave = async (report: StockReportSchema) => {
181
- const reportSystemName = (reportTypes as any).find(
182
- (reportType) => reportType.name === report.reportName,
183
- )?.systemName;
183
+ const reportSystemName = Array.isArray(reportTypes)
184
+ ? reportTypes.find((reportType) => reportType.name === report.reportName)?.systemName
185
+ : undefined;
184
186
 
185
187
  let hideSplash = true;
186
188
  try {
@@ -331,14 +333,14 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
331
333
  if (response.status === 201) {
332
334
  showSnackbar({
333
335
  title: t('batchJob', 'Batch Job'),
334
- subtitle: t('BatchJobSuccess', 'Batch job created successfully'),
336
+ subtitle: t('batchJobSuccess', 'Batch job created successfully'),
335
337
  kind: 'success',
336
338
  });
337
339
  handleMutate(`${restBaseUrl}/stockmanagement/batchjob?batchJobType=Report&v=default`);
338
340
  closeWorkspace();
339
341
  } else {
340
342
  showSnackbar({
341
- title: t('BatchJobErrorTitle', 'Batch job'),
343
+ title: t('batchJobErrorTitle', 'Batch job'),
342
344
  subtitle: t('batchJobErrorMessage', 'Error creating batch job'),
343
345
  kind: 'error',
344
346
  });
@@ -347,7 +349,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
347
349
  })
348
350
  .catch(() => {
349
351
  showSnackbar({
350
- title: t('BatchJobErrorTitle', 'Batch job'),
352
+ title: t('batchJobErrorTitle', 'Batch job'),
351
353
  subtitle: t('batchJobErrorMessage', 'Error creating batch job'),
352
354
  kind: 'error',
353
355
  });
@@ -360,6 +362,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
360
362
  }
361
363
  }
362
364
  };
365
+
363
366
  const getReportParameter = (
364
367
  name: string,
365
368
  value: string,
@@ -381,8 +384,8 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
381
384
  render={({ field: { onChange } }) => (
382
385
  <ComboBox
383
386
  id="report"
384
- labelText={t('reportName', 'Report name')}
385
- items={reportTypes}
387
+ titleText={t('reportName', 'Report name')}
388
+ items={Array.isArray(reportTypes) ? reportTypes : [reportTypes]}
386
389
  itemToString={(item) => `${item?.name ?? item?.name ?? ''}`}
387
390
  placeholder={t('filter', 'Filter...')}
388
391
  onChange={({ selectedItem }) => {
@@ -405,7 +408,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
405
408
  <ComboBox
406
409
  id="stockReportItem"
407
410
  size="md"
408
- labelText={t('stockItemCategory', 'Stock Item Category')}
411
+ titleText={t('stockItemCategory', 'Stock Item Category')}
409
412
  items={stockItemCategories}
410
413
  onChange={({ selectedItem }) => {
411
414
  onChange(selectedItem.uuid);
@@ -433,11 +436,9 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
433
436
  >
434
437
  <DatePickerInput
435
438
  id="startDate"
436
- name="startDate"
437
439
  placeholder={DATE_PICKER_FORMAT}
438
- labelText={t('startDate', 'Start Date')}
439
- defaultValue=""
440
- invalid={errors?.startDate?.message}
440
+ labelText={t('startDate', 'Start date')}
441
+ invalid={!!errors?.startDate?.message}
441
442
  invalidText={errors?.startDate?.message}
442
443
  />
443
444
  </DatePicker>
@@ -459,11 +460,9 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
459
460
  >
460
461
  <DatePickerInput
461
462
  id="endDate"
462
- name="endDate"
463
463
  placeholder={DATE_PICKER_FORMAT}
464
- labelText={t('endDate', 'End Date')}
465
- defaultValue=""
466
- invalid={errors?.endDate?.message}
464
+ labelText={t('endDate', 'End date')}
465
+ invalid={!!errors?.endDate?.message}
467
466
  invalidText={errors?.endDate?.message}
468
467
  />
469
468
  </DatePicker>
@@ -474,15 +473,15 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
474
473
  <Select
475
474
  id="inventoryGroupBy"
476
475
  defaultValue={model?.inventoryGroupBy}
477
- invalid={errors?.inventoryGroupBy?.message}
476
+ invalid={!!errors?.inventoryGroupBy?.message}
478
477
  invalidText={errors?.inventoryGroupBy?.message}
479
478
  labelText={t('inventoryBy', 'Inventory by')}
480
479
  onChange={(e) => setValue('inventoryGroupBy', e.target.value)}
481
480
  >
482
- <SelectItem value="" text={t('SelectOption', 'Select an option')} />
481
+ <SelectItem value="" text={t('selectOption', 'Select an option')} />
483
482
  <SelectItem value="StockItemOnly" text={t('stockItem', 'Stock Item')} />
484
- <SelectItem value="LocationStockItem" text={t('locationAndStockItem', 'Location and Stock Item')} />
485
- <SelectItem value="LocationStockItemBatchNo" text={t('locationAndBatchno', 'Location and Batch')} />
483
+ <SelectItem value="LocationStockItem" text={t('locationAndStockItem', 'Location and stock item')} />
484
+ <SelectItem value="LocationStockItemBatchNo" text={t('locationAndBatchNo', 'Location and batch')} />
486
485
  </Select>
487
486
  )}
488
487
  {displayLocation && (
@@ -497,7 +496,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
497
496
  setValue('location', selectedLocation?.name || '');
498
497
  }}
499
498
  defaultValue=""
500
- invalid={errors?.location?.message}
499
+ invalid={!!errors?.location?.message}
501
500
  invalidText={errors?.location?.message}
502
501
  >
503
502
  <SelectItem disabled hidden value="" text={t('chooseALocation', 'Choose a location')} />
@@ -514,7 +513,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
514
513
  <Checkbox
515
514
  id="childLocations"
516
515
  onChange={onChange}
517
- value={value}
516
+ checked={value}
518
517
  labelText={t('includeChildLocations', 'Include Child Locations')}
519
518
  />
520
519
  )}
@@ -526,7 +525,7 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
526
525
  name="mostLeastMoving"
527
526
  render={({ field: { onChange, value } }) => (
528
527
  <RadioButtonGroup name="mostLeastMoving" legendText={t('rank', 'Rank')} onChange={onChange} value={value}>
529
- <RadioButton value="MostMoving" id="mostLeastMovingMost" labelText={t('mostMoving', 'Most Moving')} />
528
+ <RadioButton value="MostMoving" id="mostLeastMovingMost" labelText={t('mostMoving', 'Most moving')} />
530
529
  <RadioButton
531
530
  value="LeastMoving"
532
531
  id="mostLeastMovingLeast"
@@ -547,9 +546,8 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
547
546
  disableWheel
548
547
  hideSteppers
549
548
  value={value}
550
- onchange={onChange}
549
+ onChange={onChange}
551
550
  label={t('limit', 'Limit')}
552
- defaultValue={20}
553
551
  />
554
552
  )}
555
553
  />
@@ -633,11 +631,9 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
633
631
  >
634
632
  <DatePickerInput
635
633
  id="date"
636
- name="date"
637
634
  placeholder={DATE_PICKER_FORMAT}
638
635
  labelText={t('date', 'Date')}
639
- defaultValue=""
640
- invalid={errors?.date?.message}
636
+ invalid={!!errors?.date?.message}
641
637
  invalidText={errors?.date?.message}
642
638
  />
643
639
  </DatePicker>
@@ -652,10 +648,10 @@ const CreateReport: React.FC<CreateReportProps> = ({ model, closeWorkspace }) =>
652
648
  [styles.desktop]: !isTablet,
653
649
  })}
654
650
  >
655
- <Button kind="secondary" onClick={closeWorkspace} className={styles.button}>
651
+ <Button kind="secondary" onClick={() => closeWorkspace()} className={styles.button}>
656
652
  {getCoreTranslation('cancel')}
657
653
  </Button>
658
- <Button type="submit" className={styles.button} onClick={handleSave}>
654
+ <Button type="submit" className={styles.button}>
659
655
  {getCoreTranslation('save')}
660
656
  </Button>
661
657
  </ButtonSet>
@@ -165,7 +165,7 @@ const StockReports: React.FC = () => {
165
165
  type="button"
166
166
  size="sm"
167
167
  className="submitButton clear-padding-margin"
168
- iconDescription={'Edit'}
168
+ iconDescription={t('edit', 'Edit')}
169
169
  kind="ghost"
170
170
  renderIcon={View}
171
171
  // onClick={(e) => onViewItem(batchJob.uuid, e)}
@@ -194,7 +194,7 @@ const StockReports: React.FC = () => {
194
194
  </div>
195
195
  ),
196
196
  }));
197
- }, [reports, onDownloadReportClick]);
197
+ }, [reports, onDownloadReportClick, t]);
198
198
 
199
199
  if (isLoading) {
200
200
  return <DataTableSkeleton role="progressbar" />;
@@ -203,12 +203,8 @@ const StockReports: React.FC = () => {
203
203
  return (
204
204
  <div className={styles.container}>
205
205
  <h2 className={styles.tableHeader}>{t('stockReportsTableHeader', 'List of reports requested by users.')}</h2>
206
- <DataTable
207
- rows={tableRows}
208
- headers={tableHeaders}
209
- isSortable={true}
210
- useZebraStyles={true}
211
- render={({ rows, headers, getHeaderProps, getTableProps, getRowProps, onInputChange }) => (
206
+ <DataTable rows={tableRows} headers={tableHeaders} isSortable useZebraStyles>
207
+ {({ rows, headers, getHeaderProps, getTableProps, getRowProps, onInputChange }) => (
212
208
  <TableContainer>
213
209
  <TableToolbar
214
210
  style={{
@@ -288,7 +284,7 @@ const StockReports: React.FC = () => {
288
284
  ) : null}
289
285
  </TableContainer>
290
286
  )}
291
- ></DataTable>
287
+ </DataTable>
292
288
  <Pagination
293
289
  page={currentPage}
294
290
  pageSize={currentPageSize}
@@ -5,7 +5,7 @@ import { useState } from 'react';
5
5
 
6
6
  export function useReportTypes() {
7
7
  const apiUrl = `${restBaseUrl}/stockmanagement/report?v=default`;
8
- const { data, error, isLoading } = useSWR<{ data: { results: ReportType } }, Error>(apiUrl, openmrsFetch);
8
+ const { data, error, isLoading } = useSWR<{ data: { results: ReportType[] } }, Error>(apiUrl, openmrsFetch);
9
9
  return {
10
10
  reportTypes: data?.data?.results ?? [],
11
11
  isLoading,
@@ -1,15 +1,15 @@
1
- import { Button, Form, Select, TextInput, SelectItem, ButtonSet, FormGroup, Stack } from '@carbon/react';
2
1
  import React, { type ChangeEvent, useCallback, useState } from 'react';
3
2
  import classNames from 'classnames';
3
+ import { Button, Form, Select, TextInput, SelectItem, ButtonSet, FormGroup, Stack } from '@carbon/react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { Save } from '@carbon/react/icons';
6
6
  import {
7
7
  getCoreTranslation,
8
8
  restBaseUrl,
9
9
  showSnackbar,
10
- type DefaultWorkspaceProps,
11
10
  useConfig,
12
11
  useLayoutType,
12
+ type DefaultWorkspaceProps,
13
13
  } from '@openmrs/esm-framework';
14
14
  import { useConcept } from '../../stock-lookups/stock-lookups.resource';
15
15
  import { type StockSource } from '../../core/api/types/stockOperation/StockSource';
@@ -62,8 +62,7 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model, closeWo
62
62
  isLowContrast: true,
63
63
  title: t('addedSource', 'Add Source'),
64
64
  kind: 'success',
65
- subtitle: t('stockSourceAddedSuccessfully', 'Stock Source Added Successfully'),
66
- timeoutInMs: 5000,
65
+ subtitle: t('stockSourceAddedSuccessfully', 'Stock source added successfully'),
67
66
  });
68
67
 
69
68
  handleMutate(`${restBaseUrl}/stockmanagement/stocksource`);
@@ -84,6 +83,7 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model, closeWo
84
83
  },
85
84
  [formModel, model, t, closeWorkspace],
86
85
  );
86
+
87
87
  return (
88
88
  <Form className={styles.container}>
89
89
  <Stack className={styles.form} gap={5}>
@@ -112,7 +112,7 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model, closeWo
112
112
  <Select
113
113
  name="sourceType"
114
114
  className="select-field"
115
- labelText={t('sourceType', 'Source Type')}
115
+ labelText={t('sourceType', 'Source type')}
116
116
  id="sourceType"
117
117
  value={formModel?.sourceType ? formModel.sourceType.uuid : ''}
118
118
  onChange={onSourceTypeChange}
@@ -129,7 +129,7 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model, closeWo
129
129
  [styles.desktop]: !isTablet,
130
130
  })}
131
131
  >
132
- <Button kind="secondary" onClick={closeWorkspace} className={styles.button}>
132
+ <Button kind="secondary" onClick={() => closeWorkspace()} className={styles.button}>
133
133
  {getCoreTranslation('cancel')}
134
134
  </Button>
135
135
  <Button type="submit" className={styles.button} onClick={handleSave} kind="primary" renderIcon={Save}>
@@ -21,11 +21,12 @@ import { useTranslation } from 'react-i18next';
21
21
  import { isDesktop, restBaseUrl } from '@openmrs/esm-framework';
22
22
  import { handleMutate } from '../utils';
23
23
  import { ResourceRepresentation } from '../core/api/api';
24
- import useStockSourcesPage from './stock-sources-items-table.resource';
24
+ import { type CustomTableHeader } from '../core/components/table/types';
25
25
  import AddStockSourceActionButton from './add-stock-source-button.component';
26
26
  import EditStockSourceActionsMenu from './edit-stock-source/edit-stock-source.component';
27
27
  import StockSourcesDeleteActionMenu from './stock-sources-delete/stock-sources-delete.component';
28
28
  import StockSourcesFilter from './stock-sources-filter/stock-sources-filter.component';
29
+ import useStockSourcesPage from './stock-sources-items-table.resource';
29
30
  import styles from './stock-sources.scss';
30
31
 
31
32
  const StockSourcesItems: React.FC = () => {
@@ -83,12 +84,8 @@ const StockSourcesItems: React.FC = () => {
83
84
  <h2 className={styles.tableHeader}>
84
85
  {t('stockSourcesTableHeader', 'List of partners who provide stock to the facility.')}
85
86
  </h2>
86
- <DataTable
87
- rows={filteredTableRows}
88
- headers={tableHeaders}
89
- isSortable
90
- useZebraStyles
91
- render={({ rows, headers, getHeaderProps, getTableProps, getRowProps, onInputChange }) => (
87
+ <DataTable rows={filteredTableRows} headers={tableHeaders} isSortable useZebraStyles>
88
+ {({ rows, headers, getHeaderProps, getTableProps, getRowProps, onInputChange }) => (
92
89
  <TableContainer>
93
90
  <TableToolbar
94
91
  style={{
@@ -125,12 +122,19 @@ const StockSourcesItems: React.FC = () => {
125
122
  <TableHeader
126
123
  {...getHeaderProps({
127
124
  header,
128
- isSortable: header.isSortable,
125
+ isSortable: (header as CustomTableHeader).isSortable,
129
126
  })}
130
127
  className={isDesktop ? styles.desktopHeader : styles.tabletHeader}
131
128
  key={`${header.key}`}
132
129
  >
133
- {header.header?.content ?? header.header}
130
+ {(() => {
131
+ const customHeader = header as CustomTableHeader;
132
+ return typeof customHeader.header === 'object' &&
133
+ customHeader.header !== null &&
134
+ 'content' in customHeader.header
135
+ ? (customHeader.header.content as React.ReactNode)
136
+ : (customHeader.header as React.ReactNode);
137
+ })()}
134
138
  </TableHeader>
135
139
  ),
136
140
  )}
@@ -164,7 +168,7 @@ const StockSourcesItems: React.FC = () => {
164
168
  ) : null}
165
169
  </TableContainer>
166
170
  )}
167
- ></DataTable>
171
+ </DataTable>
168
172
  <Pagination
169
173
  page={currentPage}
170
174
  pageSize={currentPageSize}
@@ -42,7 +42,7 @@ import {
42
42
  DATE_PICKER_CONTROL_FORMAT,
43
43
  DATE_PICKER_FORMAT,
44
44
  formatForDatePicker,
45
- INVENTORY_ADMNISTRATOR_ROLE_UUID,
45
+ INVENTORY_ADMINISTRATOR_ROLE_UUID,
46
46
  INVENTORY_CLERK_ROLE_UUID,
47
47
  INVENTORY_DISPENSING_ROLE_UUID,
48
48
  INVENTORY_MANAGER_ROLE_UUID,
@@ -124,6 +124,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
124
124
  setFilteredItems(filtered);
125
125
  }
126
126
  };
127
+
127
128
  useEffect(() => {
128
129
  if (model?.userUuid) {
129
130
  setSelectedUserUuid(model.userUuid);
@@ -133,6 +134,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
133
134
  const handleSearchQueryChange = (query: string) => {
134
135
  filterItems(query);
135
136
  };
137
+
136
138
  const onStockOperationTypeChanged = (event: React.ChangeEvent<HTMLInputElement>): void => {
137
139
  const operationType = formModel?.operationTypes?.find((x) => x.operationTypeUuid === event?.target?.value);
138
140
  if (operationType) {
@@ -187,7 +189,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
187
189
  INVENTORY_MANAGER_ROLE_UUID,
188
190
  INVENTORY_DISPENSING_ROLE_UUID,
189
191
  INVENTORY_REPORTING_ROLE_UUID,
190
- INVENTORY_ADMNISTRATOR_ROLE_UUID,
192
+ INVENTORY_ADMINISTRATOR_ROLE_UUID,
191
193
  ];
192
194
 
193
195
  const filteredStockRoles = data.selectedItem?.roles
@@ -226,7 +228,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
226
228
  isLowContrast: true,
227
229
  title: t('addUserRole', 'Add User role'),
228
230
  kind: 'success',
229
- subtitle: t('successfullysaved', 'You have successfully saved user role scope'),
231
+ subtitle: t('successfullySaved', 'You have successfully saved user role scope'),
230
232
  });
231
233
  closeWorkspace();
232
234
  },
@@ -242,32 +244,36 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
242
244
  },
243
245
  );
244
246
  };
247
+
245
248
  if (isLoading || loadingRoles || loadingUsers) {
246
249
  return (
247
250
  <InlineLoading status="active" iconDescription="Loading" description={t('loadingData', 'Loading data...')} />
248
251
  );
249
252
  }
253
+
250
254
  return (
251
255
  <Form className={styles.container}>
252
256
  <Stack className={styles.form} gap={5}>
253
257
  <div>
254
258
  {users?.results?.length > 0 && (
255
- <>
256
- <FormGroup legendText={t('user', 'User')}>
257
- <ComboBox
258
- id="userName"
259
- initialSelectedItem={usersResults.find((user) => user.uuid === model?.userUuid) ?? null}
260
- items={filteredItems.length ? filteredItems : usersResults}
261
- itemToString={(item) => `${item?.person?.display ?? item?.display ?? ''}`}
262
- labelText={t('user', 'User')}
263
- onChange={onUserChanged}
264
- onInputChange={handleSearchQueryChange}
265
- placeholder="Filter..."
266
- shouldFilterItem={() => true}
267
- size="md"
268
- />
269
- </FormGroup>
270
- </>
259
+ <FormGroup legendText={t('user', 'User')}>
260
+ <ComboBox
261
+ id="userName"
262
+ initialSelectedItem={usersResults.find((user) => user.uuid === model?.userUuid) ?? null}
263
+ items={filteredItems.length ? filteredItems : usersResults}
264
+ itemToString={(item) => {
265
+ if (!item || typeof item !== 'object') return '';
266
+ const itemWithPerson = item as { person?: { display?: string }; display?: string };
267
+ return `${itemWithPerson?.person?.display ?? itemWithPerson?.display ?? ''}`;
268
+ }}
269
+ titleText={t('user', 'User')}
270
+ onChange={onUserChanged}
271
+ onInputChange={handleSearchQueryChange}
272
+ placeholder={t('filterUsers', 'Filter users')}
273
+ shouldFilterItem={() => true}
274
+ size="md"
275
+ />
276
+ </FormGroup>
271
277
  )}
272
278
  </div>
273
279
  <Select
@@ -286,13 +292,13 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
286
292
  })
287
293
  )}
288
294
  </Select>
289
- <CheckboxGroup className={styles.checkboxGrid}>
295
+ <CheckboxGroup className={styles.checkboxGrid} legendText="">
290
296
  <Checkbox
291
297
  checked={formModel?.enabled}
292
298
  id="chk-userEnabled"
293
299
  labelText={t('enabled', 'Enabled')}
294
300
  onChange={onEnabledChanged}
295
- value={model?.enabled}
301
+ value={model?.enabled ? 'true' : 'false'}
296
302
  />
297
303
  <Checkbox
298
304
  checked={formModel?.permanent}
@@ -300,35 +306,29 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
300
306
  labelText={t('permanent', 'Permanent')}
301
307
  name="isPermanent"
302
308
  onChange={onPermanentChanged}
303
- value={model?.permanent}
309
+ value={model?.permanent ? 'true' : 'false'}
304
310
  />
305
311
 
306
312
  {!formModel?.permanent && (
307
- <>
308
- <DatePicker
309
- dateFormat={DATE_PICKER_CONTROL_FORMAT}
310
- datePickerType="range"
311
- light
312
- locale="en"
313
- minDate={formatForDatePicker(MinDate)}
314
- onChange={onActiveDatesChange}
315
- >
316
- <DatePickerInput
317
- id="date-picker-input-id-start"
318
- labelText={t('activeFrom', 'Active From')}
319
- name="activeFrom"
320
- placeholder={DATE_PICKER_FORMAT}
321
- value={formatForDatePicker(formModel?.activeFrom)}
322
- />
323
- <DatePickerInput
324
- id="date-picker-input-id-finish"
325
- labelText={t('activeTo', 'Active To')}
326
- name="activeTo"
327
- placeholder={DATE_PICKER_FORMAT}
328
- value={formatForDatePicker(formModel?.activeTo)}
329
- />
330
- </DatePicker>
331
- </>
313
+ <DatePicker
314
+ dateFormat={DATE_PICKER_CONTROL_FORMAT}
315
+ datePickerType="range"
316
+ light
317
+ locale="en"
318
+ minDate={formatForDatePicker(MinDate)}
319
+ onChange={onActiveDatesChange}
320
+ >
321
+ <DatePickerInput
322
+ id="date-picker-input-id-start"
323
+ labelText={t('activeFrom', 'Active From')}
324
+ placeholder={DATE_PICKER_FORMAT}
325
+ />
326
+ <DatePickerInput
327
+ id="date-picker-input-id-finish"
328
+ labelText={t('activeTo', 'Active To')}
329
+ placeholder={DATE_PICKER_FORMAT}
330
+ />
331
+ </DatePicker>
332
332
  )}
333
333
  </CheckboxGroup>
334
334
  <FormGroup legendText={t('stockOperations', 'Stock operations')}>
@@ -336,7 +336,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
336
336
  {t('roleDescription', 'The role will be applicable to only selected stock operations.')}
337
337
  </span>
338
338
  </FormGroup>
339
- <CheckboxGroup className={styles.checkboxGrid}>
339
+ <CheckboxGroup className={styles.checkboxGrid} legendText="">
340
340
  {stockOperations?.length > 0 &&
341
341
  stockOperations.map((type) => {
342
342
  return (
@@ -358,7 +358,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
358
358
  {t('toggleMessage', 'Use the toggle to apply this scope to the locations under the selected location.')}
359
359
  </span>
360
360
  </FormGroup>
361
- <CheckboxGroup className={styles.checkboxGrid}>
361
+ <CheckboxGroup className={styles.checkboxGrid} legendText="">
362
362
  {stockLocations?.length > 0 &&
363
363
  stockLocations.map((type) => {
364
364
  const checkedLocation = findCheckedLocation(type);
@@ -386,9 +386,8 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
386
386
  hideLabel
387
387
  id={`tg-loc-child-${type.id}`}
388
388
  key={`tg-loc-child-key-${type.id}`}
389
- onToggleClick={getToggledValue(type.id)}
389
+ toggled={getToggledValue(type.id)}
390
390
  size="sm"
391
- value={type.id}
392
391
  />
393
392
  )}
394
393
  </div>
@@ -402,10 +401,10 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({ model, ed
402
401
  [styles.desktop]: !isTablet,
403
402
  })}
404
403
  >
405
- <Button kind="secondary" onClick={closeWorkspace} className={styles.button}>
404
+ <Button kind="secondary" onClick={() => closeWorkspace()} className={styles.button}>
406
405
  {getCoreTranslation('cancel')}
407
406
  </Button>
408
- <Button type="submit" className={styles.button} onClick={addStockUserRole} renderIcon={Save}>
407
+ <Button type="submit" className={styles.button} renderIcon={Save}>
409
408
  {getCoreTranslation('save')}
410
409
  </Button>
411
410
  </ButtonSet>
@@ -29,7 +29,7 @@ const StockUserScopeDeleteActionMenu: React.FC<StockUserScopDeleteActionMenuProp
29
29
  setDeletingUserScope(false);
30
30
  showSnackbar({
31
31
  isLowContrast: true,
32
- title: t('deletingstockUserScope', 'Delete Stock User Scope'),
32
+ title: t('deletingStockUserScope', 'Delete Stock User Scope'),
33
33
  kind: 'success',
34
34
  subtitle: t('stockUserScopeDeletedSuccessfully', 'Stock User Scope Deleted Successfully'),
35
35
  });
@@ -22,7 +22,10 @@ const DeleteStockUserScopeModal: React.FC<DeleteStockUserScopeModalProps> = ({ c
22
22
  </ModalHeader>
23
23
  <ModalBody>
24
24
  <p className={styles.bodyLong01}>
25
- {t('deleteConfirmationText', "Are you sure you want to delete this User Scope? This action can't be undone.")}
25
+ {t(
26
+ 'deleteUserScopeConfirmation',
27
+ "Are you sure you want to delete this User Scope? This action can't be undone.",
28
+ )}
26
29
  </p>
27
30
  </ModalBody>
28
31
  <ModalFooter>