-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate-breadcrumbs.ts
79 lines (74 loc) · 1.94 KB
/
create-breadcrumbs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { dashboardCrumb } from "@/utils";
import { BreadCrumbConfig } from "@/components";
import { Authority } from "shared-types";
const newSubmissionPageRouteMapper: Record<
string,
{ to: string; displayText: string }
> = {
"new-submission": {
to: "/new-submission",
displayText: "Submission Type",
},
spa: {
to: "/new-submission/spa",
displayText: "SPA Type",
},
medicaid: {
to: "/new-submission/spa/medicaid",
displayText: "Medicaid SPA Type",
},
"medicaid-eligibility": {
to: "/new-submission/spa/medicaid/landing/medicaid-eligibility",
displayText:
"Medicaid Eligibility, Enrollment, Administration, and Health Homes",
},
chip: {
to: "/new-submission/spa/chip",
displayText: "CHIP SPA Type",
},
"chip-eligibility": {
to: "/new-submission/spa/chip/landing/chip-eligibility",
displayText: "CHIP Eligibility SPAs",
},
waiver: {
to: "/new-submission/waiver",
displayText: "Waiver Type",
},
b: {
to: "/new-submission/waiver/b",
displayText: "1915(b) Waiver Type",
},
b4: {
to: "/new-submission/waiver/b/b4",
displayText: "1915(b)(4) FFS Selective Contracting Waiver Types",
},
capitated: {
to: "/new-submission/waiver/b/capitated",
displayText: "1915(b) Comprehensive (Capitated) Waiver Authority Types",
},
};
export const optionCrumbsFromPath = (
path: string,
authority?: Authority,
id?: string,
): BreadCrumbConfig[] => {
const breadcrumbs = [dashboardCrumb(authority)].concat(
path.split("/").reduce<BreadCrumbConfig[]>((acc, subPath, index) => {
if (subPath in newSubmissionPageRouteMapper) {
return acc.concat({
...newSubmissionPageRouteMapper[subPath],
order: index,
});
}
return acc;
}, []),
);
if (id) {
return breadcrumbs.concat({
displayText: id,
to: `/details/${authority}/${id}`,
order: breadcrumbs.length,
});
}
return breadcrumbs;
};