Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 106x 537x 500x 36x 1x 106x 2x 2x 541x 106x 106x | import { Action } from "shared-types/actions";
import { Authority } from "shared-types/authority";
import { BreadCrumbConfig } from "@/components";
import { mapActionLabel } from "@/utils";
type DetailsAndActionsBreadCrumbsArgs = {
id: string;
authority: Authority;
actionType?: Action;
};
export const getDashboardTabForAuthority = (authority: Authority): "spas" | "waivers" => {
switch (authority) {
case "CHIP SPA" as Authority:
case "Medicaid SPA" as Authority:
return "spas";
case "1915(b)":
case "1915(c)":
return "waivers";
default:
throw new Error("Invalid authority");
}
};
export const detailsAndActionsCrumbs = ({
id,
authority,
actionType,
}: DetailsAndActionsBreadCrumbsArgs): BreadCrumbConfig[] => {
const defaultBreadCrumbs = [dashboardCrumb(authority), detailsCrumb(id, authority)];
return actionType ? [...defaultBreadCrumbs, actionCrumb(actionType, id)] : defaultBreadCrumbs;
};
export const dashboardCrumb = (authority?: Authority): BreadCrumbConfig => ({
displayText: "Dashboard",
order: 1,
to: authority ? `/dashboard?tab=${getDashboardTabForAuthority(authority)}` : "/dashboard",
});
export const detailsCrumb = (id: string, authority: Authority): BreadCrumbConfig => ({
displayText: id,
order: 2,
to: `/details/${authority}/${id}`,
});
export const actionCrumb = (action: Action, id: string): BreadCrumbConfig => ({
displayText: mapActionLabel(action),
order: 3,
to: `/actions/${id}/${action}`,
});
|