mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-01 03:45:53 -05:00
16 lines
483 B
TypeScript
16 lines
483 B
TypeScript
import React from 'react';
|
|
import { usePermissions } from '@/plugins/usePermissions';
|
|
|
|
interface Props {
|
|
action: string | string[];
|
|
matchAny?: boolean;
|
|
renderOnError?: React.ReactNode | null;
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export default function Can({ action, matchAny = false, renderOnError, children }: Props) {
|
|
const can = usePermissions(action);
|
|
|
|
return (matchAny && can.some((p) => p)) || (!matchAny && can.every((p) => p)) ? children : renderOnError;
|
|
}
|