Skip to content

Commit

Permalink
add dropdown for year selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocio De Santiago authored and Rocio De Santiago committed Jan 8, 2025
1 parent 01462a2 commit 84d216c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
36 changes: 34 additions & 2 deletions services/ui-src/src/components/modals/AddEditReportModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import React, { useState } from "react";
import { Modal, TextField } from "components";
import {
Spinner,
Expand All @@ -8,10 +8,12 @@ import {
RadioGroup,
Stack,
} from "@chakra-ui/react";
import { ElementType, Report } from "types";
import { DropdownOptions, 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,9 +23,31 @@ export const AddEditReportModal = ({
reportHandler,
}: Props) => {
const [submitting, setSubmitting] = useState<boolean>(false);
const [selectedYear, setSelectedYear] = useState<string>("");

const handleYearChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
setSelectedYear(event.target.value);
};
// add validation to formJson
const form = useForm();
const buildYears = (): DropdownOptions[] => {
const dropdownYears: DropdownOptions[] = Object.keys(Years).map(
(value) => ({
label: Years[value as unknown as keyof typeof Years],
value,
})
);
return [
{
label: "- Select a year -",
value: "",
},
...dropdownYears,
];
};

const dropdownYears = buildYears();
// const dropdownYears = { "2026": 2026, "2027": 2027, "2028": 2028];

const onSubmit = async (formData: any) => {
setSubmitting(true);
Expand Down Expand Up @@ -85,6 +109,14 @@ export const AddEditReportModal = ({
}}
formkey={"reportTitle"}
/>
<Dropdown
name="year"
id="year"
label="Select the quality measure set reporting year"
options={dropdownYears}
onChange={handleYearChange}
value={selectedYear}
/>
<strong>
Does your state administer the HCBS CAHPS beneficiary survey?
</strong>
Expand Down
9 changes: 9 additions & 0 deletions services/ui-src/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ export const PRODUCTION_HOST_DOMAIN = "mdcthcbs.cms.gov";

export const notAnsweredText = "Not answered";

// YEARS
export const Years = {
2026: "2026",
2027: "2027",
2028: "2028",
2029: "2029",
2030: "2030",
} as const;

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

0 comments on commit 84d216c

Please sign in to comment.