import { ProjectStats, PieChartDataItem } from "@/types/analytics";
import { COLORS } from "@/constants/colors";

export const getStatusChartData = (stats: ProjectStats): PieChartDataItem[] => [
  {
    name: "Under Construction",
    value: stats.statusCounts.under_construction,
    color: COLORS.yellow,
  },
  {
    name: "Possession Soon",
    value: stats.statusCounts.possession_soon,
    color: COLORS.blue,
  },
  {
    name: "Ready Possession",
    value: stats.statusCounts.ready_possession,
    color: COLORS.green,
  },
  {
    name: "Launch",
    value: stats.statusCounts.launch,
    color: COLORS.orange,
  },
];

// TODO: need to check this conversion functions
// Format currency in Indian format (lakhs and crores)
export const formatIndianCurrency = (amount: number) => {
  const formatter = new Intl.NumberFormat("en-IN", {
    style: "currency",
    currency: "INR",
    maximumFractionDigits: 0,
  });
  return formatter.format(amount);
};

// Format Indian currency in lakhs/crores
export const formatIndianValue = (value: number) => {
  if (value >= 10000000) {
    return `${(value / 10000000).toFixed(2)} Cr`;
  } else if (value >= 100000) {
    return `${(value / 100000).toFixed(2)} L`;
  } else {
    return formatIndianCurrency(value);
  }
};
