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

fix: current project officer not being selected in edit form #1539

Merged
merged 5 commits into from
Oct 4, 2023
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
@@ -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