Skip to content

Commit

Permalink
Merge pull request #1539 from HHS/OPS-1537-Fix-project-officer-in-edi…
Browse files Browse the repository at this point in the history
…t-form

fix: current project officer not being selected in edit form
  • Loading branch information
stevtek authored Oct 4, 2023
2 parents 47c573f + 50cf63f commit 58bf355
Showing 1 changed file with 1 addition and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useEffect } from "react";
import React from "react";
import PropTypes from "prop-types";
import { useNavigate } from "react-router-dom";
import classnames from "vest/classnames";
import _ from "lodash";

import ProcurementShopSelectWithFee from "../../UI/Form/ProcurementShopSelectWithFee";
import AgreementReasonSelect from "../../UI/Form/AgreementReasonSelect";
Expand All @@ -23,7 +22,6 @@ import {
useUpdateAgreementMutation
} from "../../../api/opsAPI";
import ProjectOfficerComboBox from "../../UI/Form/ProjectOfficerComboBox";
import { getUser } from "../../../api/getUser";
import useAlert from "../../../hooks/use-alert.hooks";

/**
Expand Down Expand Up @@ -82,24 +80,6 @@ export const AgreementEditForm = ({ goBack, goToNext, isReviewMode, isEditMode,
team_members: selectedTeamMembers
} = agreement;

// This is needed due to a caching issue with the React Context - for some reason selected_project_officer
// is not updated in the parent context/props.
useEffect(() => {
const getProjectOfficerSetState = async (id) => {
const results = await getUser(id);
setSelectedProjectOfficer(results);
};

if (_.isEmpty(selectedProjectOfficer) && agreement?.project_officer) {
getProjectOfficerSetState(agreement?.project_officer).catch(console.error);
}

return () => {
setSelectedProjectOfficer({});
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const {
data: productServiceCodes,
error: errorProductServiceCodes,
Expand Down

0 comments on commit 58bf355

Please sign in to comment.