Skip to content

Commit

Permalink
Merge pull request #48109 from cretadn22/handle-same-value-submit
Browse files Browse the repository at this point in the history
[CP Staging] Update submit function in initial report field value

(cherry picked from commit 5368e47)

(CP triggered by chiragsalian)
  • Loading branch information
chiragsalian authored and OSBotify committed Aug 28, 2024
1 parent 9af65b2 commit 16cc37f
Showing 1 changed file with 7 additions and 5 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],
[policyID, reportFieldID, currentInitialValue],
);

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 16cc37f

Please sign in to comment.