From 7e0703cc8e48a2d57c3ab0af8f625e7a6093a834 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Wed, 28 Aug 2024 21:29:06 +0700 Subject: [PATCH] update submit function in initial value --- .../reportFields/ReportFieldsInitialValuePage.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx b/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx index d2f7a5e69eea..b3744cdce89f 100644 --- a/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx +++ b/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx @@ -43,19 +43,21 @@ function ReportFieldsInitialValuePage({ const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); const reportField = policy?.fieldList?.[ReportUtils.getReportFieldKey(reportFieldID)] ?? null; const availableListValuesLength = (reportField?.disabledOptions ?? []).filter((disabledListValue) => !disabledListValue).length; - - const [initialValue, setInitialValue] = useState(WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField)); + const currentInitialValue = WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField); + const [initialValue, setInitialValue] = useState(currentInitialValue); const submitForm = useCallback( (values: FormOnyxValues) => { - ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === values.initialValue ? '' : values.initialValue); + if (currentInitialValue !== values.initialValue) { + ReportField.updateReportFieldInitialValue(policyID, reportFieldID, values.initialValue); + } Navigation.goBack(); }, [policyID, reportFieldID, initialValue], ); const submitListValueUpdate = (value: string) => { - ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === value ? '' : value); + ReportField.updateReportFieldInitialValue(policyID, reportFieldID, currentInitialValue === value ? '' : value); Navigation.goBack(); };