import React from 'react'; import { FileText, CheckCircle, AlertCircle, Calendar, Users, Receipt, Ticket, Download, RefreshCw } from 'lucide-react'; interface ReportsExportTabProps { dateFilter: 'all' | 'this_month' | 'last_30_days' | 'custom'; startDate: string; endDate: string; downloadingReport: string | null; successMessage: string | null; errorMessage: string | null; totalUsers: number; totalPayments: number; totalSubscriptions: number; totalCoupons: number; onDateFilterChange: (filter: 'all' | 'this_month' | 'last_30_days' | 'custom') => void; onStartDateChange: (val: string) => void; onEndDateChange: (val: string) => void; onDownloadReport: (reportKey: string) => void; } export const ReportsExportTab: React.FC = ({ dateFilter, startDate, endDate, downloadingReport, successMessage, errorMessage, totalUsers, totalPayments, totalSubscriptions, totalCoupons, onDateFilterChange, onStartDateChange, onEndDateChange, onDownloadReport, }) => { return (
{/* Top Header Card */}
Export Utilities & Financial Ledgers

Reports & Financial Export Hub

Generate and download audit-compliant CSV spreadsheets for registered customers, Razorpay payment transactions and sales revenue, active subscriber entitlements, and promotional coupon redemptions.

{/* Notifications */} {successMessage && (
{successMessage}
)} {errorMessage && (
{errorMessage}
)} {/* Filter Bar: Date Range Selector */}
Date Window: {[ { id: 'all' as const, label: 'All Time' }, { id: 'this_month' as const, label: 'This Month' }, { id: 'last_30_days' as const, label: 'Last 30 Days' }, { id: 'custom' as const, label: 'Custom Range' }, ].map((f) => ( ))}
{dateFilter === 'custom' && (
onStartDateChange(e.target.value)} className="bg-white border border-slate-200 rounded-xl px-3 py-1.5 text-xs text-slate-800 font-semibold focus:outline-none focus:border-indigo-500 shadow-sm cursor-pointer" /> to onEndDateChange(e.target.value)} className="bg-white border border-slate-200 rounded-xl px-3 py-1.5 text-xs text-slate-800 font-semibold focus:outline-none focus:border-indigo-500 shadow-sm cursor-pointer" />
)}
{/* 4 Report Cards Grid */}
{/* Report 1: Customers Ledger */}
{totalUsers} Total Users

Customers & Practitioners Ledger

Export complete customer database with contact details, country, active subscription counts, active plans, total order counts, and cumulative lifetime spend.

Included Columns: User ID, Email, Name, Phone, Role, Spend (INR/USD/EUR)
Target Audience: CRM & Growth Audits
{/* Report 2: Financial & Revenue Ledger */}
{totalPayments} Total Orders

Payments & Revenue Ledger

Accounting & transaction ledger containing Razorpay Payment IDs, invoice numbers, base plan fees, coupon discounts, order currency, and total amounts paid.

Financial Scope: Collected Revenue & Order Totals
Primary Use: Financial Reconciliation & Revenue Auditing
{/* Report 3: Subscriptions Ledger */}
{totalSubscriptions} Subscriptions

Subscriptions & Entitlements Ledger

Export clinical plan access records, customer identities, subscription status, billing cycle, auto-renewal flag, activation dates, expiration dates, and remaining days.

Metrics Included: Country, Plan Currency, Status, Days Remaining
Primary Use: Churn & Expiration Tracking
{/* Report 4: Coupon Redemptions */}
{totalCoupons} Promo Codes

Promotions & Coupon Redemptions

Track coupon performance and redemptions across orders, including discount rates, caps, customer emails, associated invoices, and total discount value granted.

Campaign Metrics: Code, Category, Discounts & Caps (INR/USD/EUR)
Primary Use: Marketing & Partner ROI
); };