'use client'; import React from 'react'; import { ComparisonItem } from '@/types'; import { Zap, CheckCircle2, TrendingDown } from 'lucide-react'; interface BreakEvenChartProps { currentQty: number; chosenTech: 'offset' | 'digital'; comparisonTable?: ComparisonItem[]; breakEvenQty?: number; reason?: string; } export const BreakEvenChart: React.FC = ({ currentQty, chosenTech, comparisonTable = [], breakEvenQty = 300, reason, }) => { if (!comparisonTable || comparisonTable.length === 0) return null; const maxPrice = Math.max(...comparisonTable.map((c) => Math.max(c.digitalTotal, c.offsetTotal))); return (
{/* Khuyến nghị ngắn gọn */} {reason && (
{reason}
)} {/* Biểu đồ cột tinh giản */}
So sánh chi phí theo số lượng
In Nhanh KTS In Offset
{comparisonTable.map((item) => { const digHeight = Math.max(8, Math.round((item.digitalTotal / maxPrice) * 95)); const offHeight = Math.max(8, Math.round((item.offsetTotal / maxPrice) * 95)); const isCurrent = item.quantity === currentQty; return (
{/* Tooltip */}
KTS: {item.digitalTotal.toLocaleString('vi-VN')}đ | Offset: {item.offsetTotal.toLocaleString('vi-VN')}đ
{item.quantity >= 1000 ? `${item.quantity / 1000}k` : item.quantity}
); })}
Điểm chuyển giao hòa vốn: ~{breakEvenQty.toLocaleString('vi-VN')} chiếc
); };