misc_pterodactyl-panel/resources/scripts/hoc/RequireServerPermission.tsx
2021-01-13 09:53:09 -07:00

26 lines
756 B
TypeScript

import React from 'react';
import Can from '@/components/elements/Can';
import ScreenBlock from '@/components/screens/ScreenBlock';
export interface RequireServerPermissionProps {
permissions: string | string[]
}
const RequireServerPermission: React.FC<RequireServerPermissionProps> = ({ children, permissions }) => {
return (
<Can
action={permissions}
renderOnError={
<ScreenBlock
image={'/assets/svgs/server_error.svg'}
title={'Access Denied'}
message={'You do not have permission to access this page.'}
/>
}
>
{children}
</Can>
);
};
export default RequireServerPermission;