Skip to content

Commit

Permalink
chore: additional reporting data form
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia committed Jan 16, 2025
1 parent e85e0b0 commit b50e25b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HasReportVersion } from "@reporting/src/app/utils/defaultPageFactoryTyp
const REGULATED_OPERATION = "OBPS Regulated Operation";
const NEW_ENTRANT = "New Entrant Operation";

function transformReportAdditionalData(reportAdditionalData: any) {
export function transformReportAdditionalData(reportAdditionalData: any) {
const captureType = [];
if (reportAdditionalData.emissions_on_site_use !== null) {
captureType.push("On-site use");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ReviewData } from "./reviewDataFactory/factory";
import { withTheme } from "@rjsf/core";
import { customizeValidator } from "@rjsf/validator-ajv8";
import finalReviewTheme from "./formCustomization/finalReviewTheme";
import { additionalReportingDataUiSchema } from "@reporting/src/data/jsonSchema/additionalReportingData/additionalReportingData";

interface Props extends HasReportVersion {
taskListElements: TaskListElement[];
Expand All @@ -25,6 +26,7 @@ const finalReviewSchemaMap: { [key: string]: any } = {
nonAttributableEmissions: nonAttributableEmissionUiSchema,
productionData: productionDataUiSchema,
emissionAllocation: emissionAllocationUiSchema,
additionalReportingData: additionalReportingDataUiSchema,
};

const resolveUiSchema = (uiSchema: any) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ReviewDataFactoryItem } from "./factory";
import { getReportAdditionalData } from "@reporting/src/app/utils/getReportAdditionalData";
import { transformReportAdditionalData } from "../../additionalInformation/additionalReportingData/AdditionalReportingDataPage";
import {
additionalReportingDataSchema,
additionalReportingDataWithElectricityGeneratedSchema,
} from "@reporting/src/data/jsonSchema/additionalReportingData/additionalReportingData";
import { getRegistrationPurpose } from "@reporting/src/app/utils/getRegistrationPurpose";

const additionalReportingDataFactoryItem: ReviewDataFactoryItem = async (
versionId,
) => {
const isRegulatedOperation =
(await getRegistrationPurpose(versionId))?.registration_purpose ===
"OBPS Regulated Operation";

const reportAdditionalData = await getReportAdditionalData(versionId);
const transformedData = transformReportAdditionalData(reportAdditionalData);

return [
{
schema: isRegulatedOperation
? additionalReportingDataWithElectricityGeneratedSchema
: additionalReportingDataSchema,
data: transformedData,
uiSchema: "additionalReportingData",
},
];
};

export default additionalReportingDataFactoryItem;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import emissionsSummaryFactoryItem from "./emissionsSummaryFactoryItem";
import productionDataFactoryItem from "./productionDataFactoryItem";
import allocationOfEmissionsFactoryItem from "./allocationOfEmissions";
import { RJSFSchema } from "@rjsf/utils";
import additionalReportingDataFactoryItem from "./additionalReportingData";

export type ReviewData = {
schema: RJSFSchema;
Expand All @@ -32,5 +33,6 @@ export default async function reviewDataFactory(
...(await emissionsSummaryFactoryItem(versionId, facilityId)),
...(await productionDataFactoryItem(versionId, facilityId)),
...(await allocationOfEmissionsFactoryItem(versionId, facilityId)),
...(await additionalReportingDataFactoryItem(versionId, facilityId)),
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import FieldTemplate from "@bciers/components/form/fields/FieldTemplate";
import { TitleOnlyFieldTemplate } from "@bciers/components/form/fields";
import SectionFieldTemplate from "@bciers/components/form/fields/SectionFieldTemplate";
import { CapturedEmmissionsInfo } from "@reporting/src/data/jsonSchema/additionalReportingData/additionalMessage";
import { RadioWidget } from "@bciers/components/form/widgets";
import multiSelectWidget from "@bciers/components/form/widgets/MultiSelectWidget";
import RadioWidget from "@bciers/components/form/widgets/RadioWidget";
import MultiSelectWidget from "@bciers/components/form/widgets/MultiSelectWidget";

export const additionalReportingDataSchema: RJSFSchema = {
type: "object",
Expand Down Expand Up @@ -132,7 +132,7 @@ export const additionalReportingDataUiSchema = {
"ui:widget": RadioWidget,
},
capture_type: {
"ui:widget": multiSelectWidget,
"ui:widget": MultiSelectWidget,
"ui:options": { style: { width: "100%", textAlign: "justify" } },
"ui:placeholder": "Capture type",
},
Expand Down

0 comments on commit b50e25b

Please sign in to comment.