Skip to content

Commit

Permalink
fix: fix reversed calculated values and add to formContext
Browse files Browse the repository at this point in the history
  • Loading branch information
BCerki committed Jan 17, 2023
1 parent 6b85e99 commit 372f3d0
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions app/components/Form/ProjectMilestoneReportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useUpdateReportingRequirementFormChange } from "mutations/ProjectReport
import { MutableRefObject, useMemo, useRef } from "react";
import { graphql, useFragment } from "react-relay";
import CollapsibleReport from "components/ReportingRequirement/CollapsibleReport";

import SavingIndicator from "./SavingIndicator";
import UndoChangesButton from "./UndoChangesButton";
import milestoneUiSchema from "data/jsonSchemaForm/projectMilestoneUiSchema";
Expand Down Expand Up @@ -273,15 +272,6 @@ const ProjectMilestoneReportForm: React.FC<Props> = (props) => {
</Button>
{sortedMilestoneReports.map((node, index) => {
const formData = { ...node.newFormData };
formData.calculatedGrossAmount = Number(
node.calculatedGrossAmountThisMilestone
);
formData.calculatedHoldbackAmount = Number(
node.calculatedNetAmountThisMilestone
);
formData.calculatedNetAmount = Number(
node.calculatedHoldbackAmountThisMilestone
);
return (
<div key={node.id} id={`Milestone${index + 1}`}>
<CollapsibleReport
Expand Down Expand Up @@ -316,6 +306,11 @@ const ProjectMilestoneReportForm: React.FC<Props> = (props) => {
ObjectFieldTemplate={EmptyObjectFieldTemplate}
formContext={{
dueDate: formData?.reportDueDate,
calculatedGrossAmount:
node.calculatedGrossAmountThisMilestone,
calculatedHoldbackAmount:
node.calculatedHoldbackAmountThisMilestone,
calculatedNetAmount: node.calculatedNetAmountThisMilestone,
}}
/>
</CollapsibleReport>
Expand Down

0 comments on commit 372f3d0

Please sign in to comment.