import {
  PRD_DRAW_RESULT_MANAGE,
  PRD_DRAW_RESULT_VIEW,
  PRD_PAYOUT_MANAGE,
  PRD_PAYOUT_REVIEW,
  PRD_PAYOUT_VIEW,
  PRD_REPORT_VIEW,
  PRD_USERS_VIEW_FINANCE,
} from "@/lib/admin-prd";
import { adminHasAnyPermission } from "@/lib/admin-permissions";

export function canManageDrawResults(permissions: readonly string[] | undefined): boolean {
  return adminHasAnyPermission(permissions, [PRD_DRAW_RESULT_MANAGE]);
}

export function canViewDrawFinance(permissions: readonly string[] | undefined): boolean {
  return (
    canManageDrawResults(permissions) ||
    adminHasAnyPermission(permissions, [
      PRD_PAYOUT_VIEW,
      PRD_PAYOUT_MANAGE,
      PRD_PAYOUT_REVIEW,
      PRD_REPORT_VIEW,
      PRD_USERS_VIEW_FINANCE,
    ])
  );
}

export function canViewDrawResults(permissions: readonly string[] | undefined): boolean {
  return adminHasAnyPermission(permissions, [PRD_DRAW_RESULT_VIEW, PRD_DRAW_RESULT_MANAGE]);
}
