diff --git a/bciers/apps/reporting/src/app/components/finalReview/formCustomization/FinalReviewMultiSelectWidget.tsx b/bciers/apps/reporting/src/app/components/finalReview/formCustomization/FinalReviewMultiSelectWidget.tsx new file mode 100644 index 0000000000..fd3c4b651b --- /dev/null +++ b/bciers/apps/reporting/src/app/components/finalReview/formCustomization/FinalReviewMultiSelectWidget.tsx @@ -0,0 +1,34 @@ +import { WidgetProps } from "@rjsf/utils/lib/types"; +import { + FieldSchema, + mapOptions, +} from "@bciers/components/form/widgets/MultiSelectWidget"; + +const FinalReviewMultiSelectWidget: React.FC = ({ + id, + value, + schema, + uiSchema, +}) => { + const fieldSchema = schema.items as FieldSchema; + const options = mapOptions(fieldSchema); + const selectedOptions = options.filter((option) => value.includes(option.id)); + const displayInline = uiSchema?.["ui:inline"]; + const separator = displayInline ? ", " : ",\n"; + + const displayOptions = selectedOptions + .map((option) => `- ${option.label}`) + .join(separator); + + return ( +
+ {displayOptions} +
+ ); +}; + +export default FinalReviewMultiSelectWidget; diff --git a/bciers/apps/reporting/src/app/components/finalReview/formCustomization/finalReviewTheme.tsx b/bciers/apps/reporting/src/app/components/finalReview/formCustomization/finalReviewTheme.tsx index d95ba5157c..fcf7419e14 100644 --- a/bciers/apps/reporting/src/app/components/finalReview/formCustomization/finalReviewTheme.tsx +++ b/bciers/apps/reporting/src/app/components/finalReview/formCustomization/finalReviewTheme.tsx @@ -2,15 +2,21 @@ import readOnlyTheme from "@bciers/components/form/theme/readOnlyTheme"; import FinalReviewFieldTemplate from "./FinalReviewFieldTemplate"; import FinalReviewStringField from "./FinalReviewStringField"; import FinalReviewArrayFieldTemplate from "./FinalReviewArrayFieldTemplate"; +import FinalReviewMultiSelectWidget from "./FinalReviewMultiSelectWidget"; const finalReviewTheme = { ...readOnlyTheme, + widgets: { + ...readOnlyTheme.widgets, + MultiSelectWidget: FinalReviewMultiSelectWidget, + }, templates: { ...readOnlyTheme.templates, FieldTemplate: FinalReviewFieldTemplate, ArrayFieldTemplate: FinalReviewArrayFieldTemplate, }, fields: { + ...readOnlyTheme.fields, StringField: FinalReviewStringField, }, }; diff --git a/bciers/apps/reporting/src/app/components/finalReview/reviewDataFactory/operationReviewFactoryItem.ts b/bciers/apps/reporting/src/app/components/finalReview/reviewDataFactory/operationReviewFactoryItem.ts index 57e1e3c249..5e3cafe8e8 100644 --- a/bciers/apps/reporting/src/app/components/finalReview/reviewDataFactory/operationReviewFactoryItem.ts +++ b/bciers/apps/reporting/src/app/components/finalReview/reviewDataFactory/operationReviewFactoryItem.ts @@ -1,15 +1,44 @@ import { operationReviewSchema, operationReviewUiSchema, + updateSchema, } from "@reporting/src/data/jsonSchema/operations"; import { ReviewDataFactoryItem } from "./factory"; import { getReportingOperation } from "@reporting/src/app/utils/getReportingOperation"; +import { getReportingYear } from "@reporting/src/app/utils/getReportingYear"; +import { formatDate } from "@reporting/src/app/utils/formatDate"; +import { getRegistrationPurpose } from "@reporting/src/app/utils/getRegistrationPurpose"; +import { getAllActivities } from "@reporting/src/app/utils/getAllReportingActivities"; +import { getRegulatedProducts } from "@bciers/actions/api"; const operationReviewFactoryItem: ReviewDataFactoryItem = async (versionId) => { + const formData = await getReportingOperation(versionId); + + const reportingYear = await getReportingYear(); + const reportingWindowEnd = formatDate( + reportingYear.reporting_window_end, + "MMM DD YYYY", + ); + + const registrationPurpose = (await getRegistrationPurpose(versionId)) + .registration_purpose; + + const allActivities = await getAllActivities(); + const allRegulatedProducts = await getRegulatedProducts(); + + const schema: any = updateSchema( + operationReviewSchema, + formData, + registrationPurpose, + reportingWindowEnd, + allActivities, + allRegulatedProducts, + ); + return [ { - schema: operationReviewSchema, - data: await getReportingOperation(versionId), + schema: schema, + data: formData, uiSchema: operationReviewUiSchema, }, ];