Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] Update submit function in initial report field value #48109

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading