diff --git a/client/packages/requisitions/src/RequestRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx b/client/packages/requisitions/src/RequestRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx
index b4b1932b90..d4c280f468 100644
--- a/client/packages/requisitions/src/RequestRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx
+++ b/client/packages/requisitions/src/RequestRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx
@@ -48,8 +48,8 @@ const InputWithLabel = ({
const errorHandler = useCallback(
(res: any) => {
// probably shouldn't be any, but UpdateIndicatorValue doesn't have res.error.__typename
- if (res?.__typename === 'UpdateIndicatorValueError') {
- if (res?.error?.__typename === 'RecordNotFound') {
+ if (res.__typename === 'UpdateIndicatorValueError') {
+ if (res.error?.__typename === 'RecordNotFound') {
error(t('messages.record-not-found'))();
} else {
error(t('error.value-type-not-correct'))();
diff --git a/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorEditPage.tsx b/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorEditPage.tsx
index 5511968bc8..f1bbacd623 100644
--- a/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorEditPage.tsx
+++ b/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorEditPage.tsx
@@ -61,7 +61,7 @@ export const IndicatorEditPage = () => {
},
[2, 3]
);
- }, [programIndicatorLineId]);
+ }, [programIndicatorLineId, programIndicators]);
if (isLoading || isProgramIndicatorsLoading) {
return ;
diff --git a/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx b/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx
index 48ebc68f37..d622d4299f 100644
--- a/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx
+++ b/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/IndicatorLineEdit.tsx
@@ -30,9 +30,11 @@ const INPUT_WIDTH = 185;
const LABEL_WIDTH = '150px';
const InputWithLabel = ({
+ autoFocus,
data,
disabled,
}: {
+ autoFocus: boolean;
data: IndicatorColumnNode;
disabled: boolean;
}) => {
@@ -56,6 +58,12 @@ const InputWithLabel = ({
},
[t]
);
+
+ const sharedProps = {
+ disabled,
+ autoFocus,
+ };
+
const inputComponent =
data.valueType === IndicatorValueTypeNode.Number ? (
) : (
{
update({ value: e.target.value }).then(errorHandler);
}}
- disabled={disabled}
- autoFocus
+ {...sharedProps}
/>
);
@@ -106,9 +112,14 @@ export const IndicatorLineEdit = ({
return (
<>
- {columns?.map(c => {
+ {columns?.map((c, i) => {
return (
-
+
);
})}
diff --git a/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/hooks.tsx b/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/hooks.tsx
index c8499fb564..f0346a7909 100644
--- a/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/hooks.tsx
+++ b/client/packages/requisitions/src/ResponseRequisition/DetailView/IndicatorEdit/hooks.tsx
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { useResponse } from '../../api';
-import { useDebounceCallback } from '@common/hooks';
+import { useDebounceCallback, useNotification } from '@common/hooks';
import {
IndicatorLineRowFragment,
IndicatorValueFragment,
@@ -44,10 +44,12 @@ export const useDraftIndicatorValue = (
) => {
const { mutateAsync, isLoading } =
useResponse.document.updateIndicatorValue();
+ const { error } = useNotification();
+
const [draft, setDraft] = useState(indicatorValue);
const save = useDebounceCallback(
(patch: Partial) =>
- mutateAsync({ ...draft, ...patch }),
+ mutateAsync({ ...draft, ...patch }).catch(e => error(e.message)()),
[],
500
);
diff --git a/client/packages/requisitions/src/ResponseRequisition/api/api.ts b/client/packages/requisitions/src/ResponseRequisition/api/api.ts
index 6620ccf59b..bc45aae5a7 100644
--- a/client/packages/requisitions/src/ResponseRequisition/api/api.ts
+++ b/client/packages/requisitions/src/ResponseRequisition/api/api.ts
@@ -307,12 +307,16 @@ export const getResponseQueries = (sdk: Sdk, storeId: string) => ({
const result = await sdk.customerProgramSettings({ storeId });
return result.customerProgramRequisitionSettings;
},
- getIndicators: async (customerNameLinkId: string, periodId: string, programId: string) => {
+ getIndicators: async (
+ customerNameLinkId: string,
+ periodId: string,
+ programId: string
+ ) => {
let result = await sdk.programIndicators({
storeId,
customerNameLinkId,
periodId,
- programId
+ programId,
});
if (result?.programIndicators.__typename === 'ProgramIndicatorConnector') {
@@ -321,7 +325,7 @@ export const getResponseQueries = (sdk: Sdk, storeId: string) => ({
},
updateIndicatorValue: async (patch: UpdateIndicatorValueInput) => {
let result = await sdk.updateIndicatorValue({ storeId, input: patch });
-
+
if (!!result?.updateIndicatorValue) {
return result.updateIndicatorValue;
}