Skip to content

Commit

Permalink
update submit function in initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
cretadn22 committed Aug 28, 2024
1 parent 6ca91cd commit 7e0703c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof ONYXKEYS.FORMS.WORKSPACE_REPORT_FIELDS_FORM>) => {
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === values.initialValue ? '' : values.initialValue);
if (currentInitialValue !== values.initialValue) {
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, values.initialValue);
}
Navigation.goBack();
},
[policyID, reportFieldID, initialValue],

Check warning on line 56 in src/pages/workspace/reportFields/ReportFieldsInitialValuePage.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

React Hook useCallback has a missing dependency: 'currentInitialValue'. Either include it or remove the dependency array
);

const submitListValueUpdate = (value: string) => {
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, initialValue === value ? '' : value);
ReportField.updateReportFieldInitialValue(policyID, reportFieldID, currentInitialValue === value ? '' : value);
Navigation.goBack();
};

Expand Down

0 comments on commit 7e0703c

Please sign in to comment.