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 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import { useState } from "react";
import PropTypes from "prop-types";
import { parse } from "cookie";
import { jwtDecode } from "jwt-decode";
import SanitizedContent from "../../SanitizedContent";
import AnimationGroup from "../AnimationGroup/AnimationGroup";
import SelectRole from "./SelectRole";
import { loadRoleOptions } from "./SelectRole/utils";
const LevelOneContent = ({ isExpanded, levelOneContent }) => {
const {
qpp_auth_token,
qpp_has_authorizations: hasAuthorizations,
qpp_cms_internal_authorized: cmsInternalRoleValues,
} = parse(document.cookie);
const roleOptions = loadRoleOptions([
hasAuthorizations,
cmsInternalRoleValues,
]);
const [selectedRole, setSelectedRole] = useState("");
let name = "";
Eif (qpp_auth_token) {
const { firstName, lastName } = jwtDecode(qpp_auth_token);
name = `${firstName} ${lastName}`;
}
const path = window.location.pathname;
document.cookie = `current_path=${path}; Path=/;`;
const hasMultipleRoles = roleOptions.length > 1;
return (
<div className="sidebar-content">
<AnimationGroup display={isExpanded}>
<h1 className="label">{name}</h1>
</AnimationGroup>
<div className="level-one-nav animation-flat">
{hasMultipleRoles && (
<SelectRole
selectedRole={selectedRole}
setSelectedRole={setSelectedRole}
roleOptions={roleOptions}
/>
)}
<SanitizedContent html={levelOneContent} />
</div>
</div>
);
};
LevelOneContent.propTypes = {
isExpanded: PropTypes.bool,
levelOneContent: PropTypes.object,
};
export default LevelOneContent;
|