Skip to content

Commit

Permalink
feat(initial submission): Establish CHIP SPA front-end submission form (
Browse files Browse the repository at this point in the history
#255)

* Copy/paste and wire in chip spa from medicaid spa base

* Extraction of some common tooling

* Further refinement of zod stuff

* Update medicaid spa form to use zod tools

* Extract content; Extract modals

* Update breadcrumbs

* Change reandered medicaid form to include modal wrapper

* Remove optional chains for defined value

* Fix zod attacahment required logic

* Update error messages

* Remove authority for chip spa details

* Text updates

* Remove unused imports

* Refactor handleSubmit instantiation

* Rewire modals with typesafe layer

* Fix breadcrumb test

* Ignore nodemodules tests
  • Loading branch information
Kevin Haube authored Dec 19, 2023
1 parent e4a9f3b commit e83c99c
Show file tree
Hide file tree
Showing 28 changed files with 881 additions and 454 deletions.
3 changes: 3 additions & 0 deletions src/packages/shared-types/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { s3ParseUrl } from "shared-utils/s3-url-parser";
export const attachmentTitleMap: Record<string, string> = {
// SPA
cmsForm179: "CMS Form 179",
currentStatePlan: "Current State Plan",
spaPages: "SPA Pages",
coverLetter: "Cover Letter",
tribalEngagement: "Tribal Engagement",
existingStatePlanPages: "Existing State Plan Pages",
publicNotice: "Public Notice",
sfq: "SFQ",
tribalConsultation: "Tribal Consultation",
amendedLanguage: "Amended Language",
budgetDocuments: "Budget Documents",
// ISSUE RAI
formalRaiLetter: "Formal RAI Letter",
// RAI RESPONSE
Expand Down
7 changes: 7 additions & 0 deletions src/packages/shared-types/authority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ export enum Authority {
MED_SPA = "medicaid spa",
CHIP_SPA = "chip spa",
}

export const isSpa = (planType: string | undefined) =>
!planType
? false
: [Authority.MED_SPA, Authority.CHIP_SPA].includes(
planType.toLowerCase() as Authority
);
1 change: 1 addition & 0 deletions src/packages/shared-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export * from "./authority";
export * from "./action-types";
export * from "./forms";
export * from "./inputs";
export * from "./states";
export * from "./statusHelper";
62 changes: 62 additions & 0 deletions src/packages/shared-types/states.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
export const STATE_CODES = [
"AL",
"AK",
"AS",
"AZ",
"AR",
"CA",
"CO",
"CT",
"DE",
"DC",
"FM",
"FL",
"GA",
"GU",
"HI",
"ID",
"IL",
"IN",
"IA",
"KS",
"KY",
"LA",
"ME",
"MH",
"MD",
"MA",
"MI",
"MN",
"MS",
"MO",
"MT",
"NE",
"NV",
"NH",
"NJ",
"NM",
"NY",
"NC",
"ND",
"MP",
"OH",
"OK",
"OR",
"PW",
"PA",
"PR",
"RI",
"SC",
"SD",
"TN",
"TX",
"UT",
"VT",
"VI",
"VA",
"WA",
"WV",
"WI",
"WY",
] as const;
export type StateCode = typeof STATE_CODES[number];
12 changes: 9 additions & 3 deletions src/services/ui/src/api/useGetItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { API } from "aws-amplify";
import { ItemResult, ReactQueryApiError } from "shared-types";

export const getItem = async (id: string): Promise<ItemResult> => {
const record = await API.post("os", "/item", { body: { id } });
export const getItem = async (id: string): Promise<ItemResult> =>
await API.post("os", "/item", { body: { id } });

return record;
export const idIsUnique = async (id: string) => {
try {
await getItem(id);
return false;
} catch (e) {
return true;
}
};

export const useGetItem = (
Expand Down
6 changes: 3 additions & 3 deletions src/services/ui/src/components/BreadCrumb/BreadCrumb.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ describe("Bread Crumb Tests", () => {
render(
<>
<Routes>
<Route path="/" />
<Route path="/test" />
<Route path="/test/:id" />
<Route path="/" element={<p>Fail</p>} />
<Route path="/test" element={<p>Success</p>} />
<Route path="/test/:id" element={<p>Fail</p>} />
</Routes>
<BreadCrumbBar>
<BreadCrumb to="/test">Click Me</BreadCrumb>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { format } from "date-fns";
import { OsMainSourceItem } from "shared-types";
import { isSpa, OsMainSourceItem } from "shared-types";
import { removeUnderscoresAndCapitalize } from "@/utils";
import { LABELS } from "@/lib";
import { BLANK_VALUE } from "@/consts";

export const ChipSpaPackageDetails = (data: OsMainSourceItem) => {
if (!data) return null;
const actionType =
data.planType === "Medicaid SPA"
? []
: [
{
label: "Action Type",
value: data.actionType
? LABELS[data.actionType as keyof typeof LABELS] ||
data.actionType
: BLANK_VALUE,
},
];
const actionType = isSpa(data.planType)
? []
: [
{
label: "Action Type",
value: data.actionType
? LABELS[data.actionType as keyof typeof LABELS] || data.actionType
: BLANK_VALUE,
},
];

const detailFields = [
{
Expand Down
33 changes: 7 additions & 26 deletions src/services/ui/src/pages/actions/actions-breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
import { ROUTES } from "@/routes";
import { mapActionLabel } from "@/utils";
import { Action } from "shared-types";
import { BreadCrumbConfig } from "@/components";
import { actionCrumb, dashboardCrumb, detailsCrumb } from "@/utils/crumbs";

export const DETAILS_AND_ACTIONS_CRUMBS = (data: {
export const DETAILS_AND_ACTIONS_CRUMBS = ({
id,
action,
}: {
id: string;
action?: Action;
}): BreadCrumbConfig[] => {
const base = [
{
displayText: "Dashboard",
order: 1,
default: true,
to: ROUTES.DASHBOARD,
},
{
displayText: data.id,
order: 2,
to: `/details?id=${data.id}`,
},
];
return !data.action
? base
: ([
...base,
{
displayText: mapActionLabel(data.action),
order: 3,
to: `/actions/${data.id}/${data.action}`,
},
] as BreadCrumbConfig[]);
const base = [dashboardCrumb, detailsCrumb(id)];
return !action ? base : [...base, actionCrumb(action, id)];
};
36 changes: 14 additions & 22 deletions src/services/ui/src/pages/create/create-breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Specific to the path of each Options page
import { ROUTES } from "@/routes";
import { BreadCrumbConfig } from "@/components";
import { dashboardCrumb } from "@/utils/crumbs";

enum Keys {
NEW_SUBMISSION = "new-submission",
SPA_TYPE = "spa",
SPA_MEDICAID_TYPE = "medicaid",
SPA_MEDICAID_FORM = "create",
SPA_MEDICAID_LANDING_ELIGIBILITY = "medicaid-eligibility",
SPA_MEDICAID_LANDING_ABP = "medicaid-abp",
SPA_CHIP_TYPE = "chip",
Expand All @@ -21,7 +21,6 @@ const newSubmissionPageTitleMapper: Record<Keys, string> = {
[Keys.NEW_SUBMISSION]: "Submission Type",
[Keys.SPA_TYPE]: "SPA Type",
[Keys.SPA_MEDICAID_TYPE]: "Medicaid SPA Type",
[Keys.SPA_MEDICAID_FORM]: "Submit a new Medicaid SPA",
[Keys.SPA_MEDICAID_LANDING_ELIGIBILITY]:
"Medicaid Eligibility, Enrollment, Administration, and Health Homes",
[Keys.SPA_MEDICAID_LANDING_ABP]:
Expand All @@ -40,7 +39,6 @@ const newSubmissionPageRouteMapper: Record<Keys, ROUTES> = {
[Keys.NEW_SUBMISSION]: ROUTES.NEW_SUBMISSION_OPTIONS,
[Keys.SPA_TYPE]: ROUTES.SPA_SUBMISSION_OPTIONS,
[Keys.SPA_MEDICAID_TYPE]: ROUTES.MEDICAID_SPA_SUB_OPTIONS,
[Keys.SPA_MEDICAID_FORM]: ROUTES.MEDICAID_NEW,
[Keys.SPA_MEDICAID_LANDING_ELIGIBILITY]: ROUTES.MEDICAID_ELIGIBILITY_LANDING,
[Keys.SPA_MEDICAID_LANDING_ABP]: ROUTES.MEDICAID_ABP_LANDING,
[Keys.SPA_CHIP_TYPE]: ROUTES.CHIP_SPA_SUB_OPTIONS,
Expand All @@ -51,22 +49,16 @@ const newSubmissionPageRouteMapper: Record<Keys, ROUTES> = {
[Keys.WAIVER_1915B_CAP_TYPE]: ROUTES.BCAP_WAIVER_OPTIONS,
};

export const NEW_SUBMISSION_CRUMBS = (path: string) =>
[
{
default: true,
displayText: "Dashboard",
to: ROUTES.DASHBOARD,
order: 1,
},
...path
.split("/")
.map((v, idx) => {
return {
displayText: newSubmissionPageTitleMapper[v as Keys],
to: newSubmissionPageRouteMapper[v as Keys],
order: idx,
};
})
.filter((v) => v.displayText !== undefined),
] as BreadCrumbConfig[];
export const optionCrumbsFromPath = (path: string): BreadCrumbConfig[] => [
dashboardCrumb,
...path
.split("/")
.map((v, idx) => {
return {
displayText: newSubmissionPageTitleMapper[v as Keys],
to: newSubmissionPageRouteMapper[v as Keys],
order: idx,
};
})
.filter((v) => v.displayText !== undefined),
];
4 changes: 2 additions & 2 deletions src/services/ui/src/pages/create/create-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { SimplePageContainer } from "@/components";
import { BreadCrumbs } from "@/components/BreadCrumb";
import { useLocation } from "react-router-dom";
import { NEW_SUBMISSION_CRUMBS } from "@/pages/create/create-breadcrumbs";
import { optionCrumbsFromPath } from "@/pages/create/create-breadcrumbs";

/** Can be removed once page title bar with back nav is integrated */
export const SimplePageTitle = ({ title }: { title: string }) => (
Expand All @@ -36,7 +36,7 @@ const OptionsPage = ({ options, title, fieldsetLegend }: OptionsPageProps) => {
const location = useLocation();
return (
<SimplePageContainer>
<BreadCrumbs options={NEW_SUBMISSION_CRUMBS(location.pathname)} />
<BreadCrumbs options={optionCrumbsFromPath(location.pathname)} />
<SimplePageTitle title={title} />
<OptionFieldset legend={fieldsetLegend}>
{options.map((opt, idx) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SimplePageTitle } from "@/pages/create/create-options";
import { SimplePageContainer } from "@/components";
import { FAQ_SECTION, ROUTES } from "@/routes";
import { BreadCrumbs } from "@/components/BreadCrumb";
import { NEW_SUBMISSION_CRUMBS } from "@/pages/create/create-breadcrumbs";
import { optionCrumbsFromPath } from "@/pages/create/create-breadcrumbs";
export enum EXTERNAL_APP {
MAC_PRO = "https://www.medicaid.gov/resources-for-states/medicaid-and-chip-program-macpro-portal/index.html#MACPro",
MMDL = "https://wms-mmdl.cms.gov/MMDL/faces/portal.jsp",
Expand Down Expand Up @@ -56,7 +56,7 @@ const ExternalAppLandingPage = ({
const location = useLocation();
return (
<SimplePageContainer>
<BreadCrumbs options={NEW_SUBMISSION_CRUMBS(location.pathname)} />
<BreadCrumbs options={optionCrumbsFromPath(location.pathname)} />
{/* TODO: Replace simple page title bar with breadcrumbs */}
<SimplePageTitle title={pageTitle} />
<div className="flex flex-col items-center justify-center m-4 pt-4 pb-12">
Expand Down
2 changes: 1 addition & 1 deletion src/services/ui/src/pages/create/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const CHIP_SPA_OPTIONS: OptionData[] = [
{
title: "All Other CHIP SPA Submissions",
description: "Create a new CHIP State Plan Amendment",
linkTo: ROUTES.HOME,
linkTo: ROUTES.CHIP_NEW,
},
];

Expand Down
Loading

0 comments on commit e83c99c

Please sign in to comment.