import React, { useState } from 'react';
import { Head } from '@inertiajs/react';
import AdminLayout from '@/Layouts/AdminLayout';
import {
BarChart3,
TrendingUp,
Users,
CreditCard,
Percent,
Award,
Sparkles,
Calendar,
Download
} from 'lucide-react';
import { Badge } from '@/components/ui/badge';
export default function AnalyticsHub({ user_growth, revenue_breakdown, retention_rates, hiring_funnel }) {
const [selectedTab, setSelectedTab] = useState('Growth');
// Helper coordinates calculation for Cohort growth Area Chart (450w, 200h)
const getCoordinatesForArea = (key, maxVal) => {
const points = [];
const paddingLeft = 40;
const paddingRight = 15;
const paddingTop = 20;
const paddingBottom = 25;
const graphHeight = 200 - paddingTop - paddingBottom;
const graphWidth = 450 - paddingLeft - paddingRight;
user_growth.forEach((d, idx) => {
const val = d[key];
const x = paddingLeft + (idx / (user_growth.length - 1)) * graphWidth;
const y = paddingTop + graphHeight - (val / maxVal) * graphHeight;
points.push(`${x},${y}`);
});
// Add bottom-right and bottom-left to close the area shape
const startX = paddingLeft;
const endX = paddingLeft + graphWidth;
const bottomY = paddingTop + graphHeight;
return `${startX},${bottomY} ${points.join(' ')} ${endX},${bottomY}`;
};
const getLineCoordinates = (key, maxVal) => {
const points = [];
const paddingLeft = 40;
const paddingRight = 15;
const paddingTop = 20;
const paddingBottom = 25;
const graphHeight = 200 - paddingTop - paddingBottom;
const graphWidth = 450 - paddingLeft - paddingRight;
user_growth.forEach((d, idx) => {
const val = d[key];
const x = paddingLeft + (idx / (user_growth.length - 1)) * graphWidth;
const y = paddingTop + graphHeight - (val / maxVal) * graphHeight;
points.push(`${x},${y}`);
});
return points.join(' ');
};
return (
Explore subscription cohort retention, job conversions ratios, availability trends, and monthly billing splits.
Employer and Worker registry trends (6 Months)
Monthly billing splits (AED)
Hiring Conversion stage details (This month)
Month 1 to Month 6 user retention metrics