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 80 81 82 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import React from 'react';
import cookie from 'cookie';
import axios from 'axios';
import { CloseIcon } from '../../lib/SvgComponents';
import { TextButton } from '../Button';
import {
deleteImpersonatedUser,
revertQppHasAuthsCookie,
revertApmPaymentCookie,
} from '../../session/logout';
import { viewingToolUrl } from '../SideNav/helpers';
const getViewType = (viewType) =>
({
username: 'HARP ID',
npi: 'NPI',
tin: 'TIN',
apm_id: 'APM Entity',
cms_id: 'Registry',
vg_id: 'Virtual Group',
})[viewType];
const ImpersonatorBanner = () => {
const {
qpp_auth_token: token = null,
qpp_impersonated_user: user = null,
qpp_impersonated_type: viewType = null,
} = cookie.parse(document.cookie);
const className = [
'qpp-u-display--flex',
'qpp-u-justify-content--between',
'qpp-u-fill--gold-20',
'qpp-u-padding-x--40',
'qpp-u-padding-y--24',
'qpp-u-font-size--14',
'qpp-u-color--gray-80',
].join(' ');
const onClick = () => {
const fn = () => {
deleteImpersonatedUser({
qpp_impersonated_user: user,
qpp_impersonated_type: viewType,
});
// Set user_has_apm_payments cookie back to impersonator's value
revertApmPaymentCookie();
// Set qpp_has_authorizations cookie back to impersonator's value
revertQppHasAuthsCookie();
window.location.href = viewingToolUrl;
};
return axios
.delete('/api/auth/helpdesk/view', {
headers: {
Accept: 'application/vnd.qpp.cms.gov.v1+json',
Authorization: `Bearer ${token}`,
},
})
.then(fn, fn);
};
return (
token &&
user && (
<div className={className}>
<div>
VIEW ONLY | You are currently viewing {getViewType(viewType)}:{' '}
<strong>{user}</strong>
</div>
<TextButton onClick={onClick} className="qpp-u-color--gray-80">
Exit View Mode
<CloseIcon />
</TextButton>
</div>
)
);
};
export default ImpersonatorBanner;
|