Skip to content
Open
Show file tree
Hide file tree
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 @@ -303,8 +303,8 @@ export const AcquisitionContainer: React.FunctionComponent<IAcquisitionContainer
},
userOverrideCodes,
)
.then(response => {
onSuccess();
.then(async response => {
await onSuccess();
if (isValidId(response?.id)) {
pathGenerator.showFile('acquisition', response.id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ export const ResearchContainer: React.FunctionComponent<IResearchContainerProps>
return updateResearchFileProperties(
file as ApiGen_Concepts_ResearchFile,
userOverrideCodes,
).then(response => {
onSuccess();
).then(async response => {
await onSuccess();
if (isValidId(response?.id)) {
pathGenerator.showFile('research', response.id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('UpdateProperties component', () => {
);
});

it('if the update fails with a 409 the associated entities modal is displayed', async () => {
it('if the update fails with a 409 it does not show the associated entities modal', async () => {
updateFileProperties.mockRejectedValue({
isAxiosError: true,
code: '409',
Expand All @@ -373,8 +373,10 @@ describe('UpdateProperties component', () => {
await act(async () => userEvent.click(saveConfirmButton));

expect(updateFileProperties).toHaveBeenCalled();
expect(screen.getByText('Property with associations'));
expect(screen.getByText(/This property can not be removed from the file/i));
expect(screen.queryByText('Property with associations')).not.toBeInTheDocument();
expect(
screen.queryByText(/This property can not be removed from the file/i),
).not.toBeInTheDocument();
});

it('validates form values upon submission', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios, { AxiosError } from 'axios';
import { FieldArray, Formik, FormikProps } from 'formik';
import { LatLngLiteral } from 'leaflet';
import noop from 'lodash/noop';
Expand Down Expand Up @@ -175,7 +174,6 @@ export const UpdateProperties: React.FunctionComponent<IUpdatePropertiesProps> =
try {
const response = await props.updateFileProperties(file, []);

formikRef.current?.setSubmitting(false);
if (isValidId(response?.id)) {
if (file.fileProperties?.find(fp => !fp.property?.address && !fp.property?.id)) {
toast.warn(
Expand All @@ -187,10 +185,8 @@ export const UpdateProperties: React.FunctionComponent<IUpdatePropertiesProps> =
props.setIsShowingPropertySelector(false);
await props.onSuccess(true);
}
} catch (e) {
if (axios.isAxiosError(e) && (e as AxiosError).code === '409') {
setShowAssociatedEntityWarning(true);
}
} finally {
formikRef.current?.setSubmitting(false);
}
};

Expand Down
Loading