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 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 | 2x 1x 1x 1x 1x 1x 6x | import { Navigate } from "react-router";
import { UserRole } from "shared-types/events/legacy-user";
import { useGetUserDetails } from "@/api";
import { LoadingSpinner, OptionCard, OptionFieldset, SubNavHeader } from "@/components";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
type UserRoleWithNoRole = UserRole;
type RoleOptions = {
key: UserRoleWithNoRole;
title: string;
description: string;
rolesWhoCanView: UserRoleWithNoRole[];
link: string;
};
export const SignUp = () => {
const { data: userDetails } = useGetUserDetails();
const isNewUserRoleDisplay = useFeatureFlag("SHOW_USER_ROLE_UPDATE");
if (!userDetails) return <LoadingSpinner />;
const role = userDetails.role;
if (role && isNewUserRoleDisplay) return <Navigate to="/profile" />;
// helpdesk, system admins, and cms reviewer users don't even see request role as an option
const roleOptions = [
{
key: "statesubmitter",
title: "State Submitter",
description: "Responsible for submitting packages",
rolesWhoCanView: ["statesystemadmin", "norole"],
link: "/signup/state?role=statesubmitter",
},
{
key: "statesystemadmin",
title: "State System Administrator",
description: "Ability to approve state submitters and submit packages",
rolesWhoCanView: ["statesubmitter", "norole"],
link: "/signup/state?role=statesystemadmin",
},
{
key: "defaultcmsuser",
title: "CMS Read-only",
description: "Responsible for viewing packages",
rolesWhoCanView: ["cmsroleapprover"],
link: "/signup/cms",
},
{
key: "cmsroleapprover",
title: "CMS Role Approver",
description: "Responsible for managing CMS Read-only Users and State System Admins",
rolesWhoCanView: ["defaultcmsuser", "cmsreviewer"],
link: "/signup/cms",
},
] satisfies RoleOptions[];
const displayRoleOptions = roleOptions.filter((roleOption) => {
return roleOption.rolesWhoCanView.find((validRole) => validRole === role);
});
return (
<div>
<SubNavHeader>
<h1 className="text-xl font-medium">Registration: User Role</h1>
</SubNavHeader>
<OptionFieldset legend={"Select the role for which you are registering"}>
{displayRoleOptions.map((role) => (
<OptionCard
description={role.description}
title={role.title}
to={role.link}
key={role.key}
/>
))}
</OptionFieldset>
</div>
);
};
|