// Permission Gate Component
// Wrapper component that checks RBAC permissions before rendering children

import { Action, ScreenName } from '@/core/operations/permissions/permission-types';

export interface PermissionGateProps {
  // Permission check
  action?: Action;
  module?: string;
  screen?: ScreenName;
  
  // Employee context (usually from auth context)
  employeeId?: string;
  
  // Behavior
  fallback?: unknown; // Component to render if permission denied
  showError?: boolean;
  errorMessage?: string;
  
  // Children
  children?: unknown;
  
  // Loading state
  loadingComponent?: unknown;
}

/**
 * Permission Gate Component
 * 
 * Wraps content and only renders if employee has required permission.
 * Integrates with RBAC engine service.
 * 
 * Usage example (React):
 * ```tsx
 * <PermissionGate
 *   action="create"
 *   module="settlement"
 *   employeeId={employeeId}
 *   fallback={<Alert variant="warning" message="You don't have permission" />}
 * >
 *   <CreateSettlementForm />
 * </PermissionGate>
 * 
 * <PermissionGate
 *   screen="settlement"
 *   employeeId={employeeId}
 * >
 *   <SettlementScreen />
 * </PermissionGate>
 * ```
 */
export interface PermissionGateComponent {
  props: PermissionGateProps;
  checkPermission(): Promise<boolean>;
  render(): unknown;
}

