From ad21147c99c26b7cf7c412f45baac2e6023bcaf8 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Wed, 28 Aug 2024 01:16:23 +0700 Subject: [PATCH] address lint error --- .../ReportFieldsInitialValuePage.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx b/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx index ea10ea5ead25..0b2d527ccf12 100644 --- a/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx +++ b/src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx @@ -43,18 +43,14 @@ 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)); - - if (!reportField || hasAccountingConnections) { - return ; - } - const isTextFieldType = reportField.type === CONST.REPORT_FIELD_TYPES.TEXT; - const isListFieldType = reportField.type === CONST.REPORT_FIELD_TYPES.LIST; + const currentInitialValue = WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField); + const [initialValue, setInitialValue] = useState(currentInitialValue); + const isTextFieldType = reportField?.type === CONST.REPORT_FIELD_TYPES.TEXT; + const isListFieldType = reportField?.type === CONST.REPORT_FIELD_TYPES.LIST; const submit = useCallback( (value: string) => { - if (WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField) === value) { + if (currentInitialValue === value) { if (isListFieldType) { ReportField.updateReportFieldInitialValue(policyID, reportFieldID, ''); } @@ -63,14 +59,14 @@ function ReportFieldsInitialValuePage({ } Navigation.goBack(); }, - [policyID, reportFieldID, initialValue], + [policyID, reportFieldID, isListFieldType, currentInitialValue], ); const submitForm = useCallback( (values: FormOnyxValues) => { submit(values.initialValue); }, - [policyID, reportFieldID, initialValue], + [submit], ); const validateForm = useCallback( @@ -100,6 +96,10 @@ function ReportFieldsInitialValuePage({ [availableListValuesLength, policy?.fieldList, translate], ); + if (!reportField || hasAccountingConnections) { + return ; + } + return (