Skip to content

Commit

Permalink
preserve data
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocio De Santiago authored and Rocio De Santiago committed Jan 17, 2025
1 parent e30e3ed commit cda629c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
6 changes: 4 additions & 2 deletions services/app-api/handlers/reports/buildReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ export const buildReport = async (
user: User
) => {
const report = structuredClone(reportTemplates[reportType]) as Report;
// TODO: Save version to db (filled or unfilled?)

// TODO: Get version by year
if (reportOptions.year != 2026) {
throw new Error("ERROR: Year should be 2026");
}
report.state = state;
report.id = KSUID.randomSync().string;
report.created = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ const editModalComponent = (
selectedReport={
{
name: "report name thing",
options: {
cahps: "true",
hciidd: "true",
nciad: "true",
pom: "true",
},
} as unknown as any
}
/>
Expand Down
28 changes: 15 additions & 13 deletions services/ui-src/src/components/modals/AddEditReportModal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useState } from "react";
import { Modal, TextField, RadioField } from "components";
import { Spinner, Flex, Text } from "@chakra-ui/react";
import { DropdownOptions, ElementType, Report } from "types";
import { ElementType, Report } from "types";
import { createReport, putReport } from "utils/api/requestMethods/report";
import { FormProvider, useForm } from "react-hook-form";
import { ReportOptions } from "types/report";
import { Dropdown } from "@cmsgov/design-system";
import { Years } from "../../constants";

export const AddEditReportModal = ({
activeState,
Expand All @@ -21,20 +20,22 @@ export const AddEditReportModal = ({
const handleYearChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
setSelectedYear(event.target.value);
};
const buildYears = (): DropdownOptions[] => {
const dropdownYears: DropdownOptions[] = Object.keys(Years).map(
(value) => ({
label: Years[value as unknown as keyof typeof Years],
value,
})
);
return [...dropdownYears];
};

const dropdownYears = buildYears();
// TO-DO to update when we add template versioning by year
const dropdownYears = [{ label: "2026", value: 2026 }];

// add validation to formJson
const form = useForm();
const form = useForm({
defaultValues: {
name: selectedReport?.name,
year: selectedReport?.year,
cahps: selectedReport?.options.cahps,
hciidd: selectedReport?.options.hciidd,
nciad: selectedReport?.options.nciad,
pom: selectedReport?.options.pom,
},
shouldUnregister: true,
});
const onSubmit = async (formData: any) => {
setSubmitting(true);

Expand Down Expand Up @@ -98,6 +99,7 @@ export const AddEditReportModal = ({
}}
formkey={"reportTitle"}
/>
{/* TO-DO: Add DropdownField.tsx */}
<Dropdown
name="year"
id="year"
Expand Down
5 changes: 0 additions & 5 deletions services/ui-src/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ export const PRODUCTION_HOST_DOMAIN = "mdcthcbs.cms.gov";

export const notAnsweredText = "Not answered";

// YEARS
export const Years = {
2026: "2026",
} as const;

// STATES
export const StateNames = {
AL: "Alabama",
Expand Down

0 comments on commit cda629c

Please sign in to comment.