import React from 'react'
import {
ComponentShieldAuthProps,
ComponentShieldBaseProps,
ComponentShieldRBACProps,
ComponentShieldProps,
} from '../types/Component'
/**
* 🛡️ A Shield for your Components, it handles when a component shows or not based on the user's role or by a custom condition that you provide.
*
* @param ComponentShieldProps {@link ComponentShieldProps | see here}
* @returns Children Components | {@link JSX.Element}
*
*
* @example
* ```tsx
* // Basic Example
*
* You are authorized
*
*
* // Fallback Example
* You are unauthorized
}>
* You are authorized
*
*
* // RBAC Example
*
* You are an ADMIN
*
* ```
*
* @packageDocumentation
*/
export function ComponentShield(props: ComponentShieldBaseProps): JSX.Element
export function ComponentShield(props: ComponentShieldAuthProps): JSX.Element
export function ComponentShield(props: ComponentShieldRBACProps): JSX.Element
export function ComponentShield(props: ComponentShieldProps) {
const { showForRole, showIf, fallback = null, RBAC, userRole, children } = props
if (RBAC) return <>{showForRole === userRole ? children : null}>
if (showIf) return <>{children}>
return <>{fallback}>
}
// function Debug() {
// return (
// <>
//
// Default
//
//
// RBAC
//
// >
// )
// }