misc_pterodactyl-panel/resources/scripts/components/elements/Can.tsx

21 lines
443 B
TypeScript
Raw Normal View History

2020-03-29 21:19:17 +00:00
import React from 'react';
import { usePermissions } from '@/plugins/usePermissions';
interface Props {
action: string | string[];
renderOnError?: React.ReactNode | null;
children: React.ReactNode;
}
const Can = ({ action, renderOnError, children }: Props) => {
2020-03-29 21:19:17 +00:00
const can = usePermissions(action);
return (
<>
2020-03-29 21:19:17 +00:00
{can.every(p => p) ? children : renderOnError}
</>
);
};
export default Can;