Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
emyl3 committed Jun 26, 2023
1 parent 1fe2a31 commit 8455edd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/Settings/Facility/FacilityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { deviceRequiredErrMsg, facilityInfoErrMsgs } from "./constants";

export type FacilityFormData = {
facility: {
id?: string;
name: string;
phone: string;
email: string | null;
Expand All @@ -51,7 +52,6 @@ export type FacilityFormData = {
phone: string | null;
};
devices: string[];
id?: string;
};

type AddressOptions = "facility" | "provider";
Expand Down
33 changes: 17 additions & 16 deletions frontend/src/app/Settings/Facility/FacilityFormContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,23 @@ const FacilityFormContainer: any = (props: Props) => {
const [addFacilityMutation] = useAddFacilityMutation();

const [saveSuccess, updateSaveSuccess] = useState(false);
const [facilityData, setFacilityData] = useState<any | undefined>(undefined);
const [facilityData, setFacilityData] = useState<
FacilityFormData | undefined
>(undefined);
const dispatch = useDispatch();

if (loading) {
return <p> Loading... </p>;
}
if (error) {
return error;
}
if (!data) {
return <p>Error: facility not found</p>;
}

if (saveSuccess) {
dispatch(updateFacility(facilityData));
dispatch(updateFacility(facilityData?.facility));

showSuccess(
"The settings for the facility have been updated",
Expand All @@ -52,16 +64,6 @@ const FacilityFormContainer: any = (props: Props) => {
);
}

if (loading) {
return <p> Loading... </p>;
}
if (error) {
return error;
}
if (!data) {
return <p>Error: facility not found</p>;
}

const saveFacility = async (facilityData: FacilityFormData) => {
if (appInsights) {
appInsights.trackEvent({ name: "Save Settings" });
Expand Down Expand Up @@ -104,10 +106,9 @@ const FacilityFormContainer: any = (props: Props) => {
(response) => response?.data?.addFacility?.id
);

setFacilityData({
...facility,
id: savedFacilityId as string,
});
facilityData.facility.id = savedFacilityId;

setFacilityData(facilityData);
updateSaveSuccess(true);
};

Expand Down

0 comments on commit 8455edd

Please sign in to comment.