'use client';
import { Star, TrendingUp, Award, Zap } from 'lucide-react';
import type { RatingSimulator as RatingSimulatorType, WeaknessItem } from '../types';
interface RatingSimulatorProps {
simulator: RatingSimulatorType | null;
topWeaknesses?: WeaknessItem[];
}
interface RatingStarProps {
rating: number;
label: string;
color: string;
isProjected?: boolean;
}
function RatingDisplay({ rating, label, color, isProjected }: RatingStarProps) {
const fullStars = Math.floor(rating);
const partialStar = rating - fullStars;
const emptyStars = 5 - Math.ceil(rating);
return (
{label}
{/* Full stars */}
{Array.from({ length: fullStars }).map((_, i) => (
))}
{/* Partial star */}
{partialStar > 0 && (
)}
{/* Empty stars */}
{Array.from({ length: emptyStars }).map((_, i) => (
))}
{rating.toFixed(2)}
);
}
/**
* Rating simulator showing potential rating improvements.
*/
export function RatingSimulator({ simulator, topWeaknesses = [] }: RatingSimulatorProps) {
if (!simulator || simulator.potential_gain <= 0) {
return null;
}
const { current_rating, if_fix_top_1, if_fix_top_3, potential_gain } = simulator;
// Calculate progress towards 5 stars
const currentProgress = (current_rating / 5) * 100;
const potentialProgress = ((current_rating + potential_gain) / 5) * 100;
return (
Rating Simulator
+{potential_gain.toFixed(2)} potential
{/* Rating Comparisons */}
{if_fix_top_1 && (
)}
{if_fix_top_3 && (
)}
{/* Progress Bar */}
Progress to 5 Stars
{Math.min(100, potentialProgress).toFixed(0)}% achievable
{/* Current rating progress */}
{/* Potential gain overlay */}
1
2
3
4
5
{/* Action Items */}
{topWeaknesses.length > 0 && (
Priority Fixes
{topWeaknesses.slice(0, 3).map((weakness, index) => (
{index + 1}
{weakness.subcode_name}
{weakness.negative_percentage.toFixed(0)}% negative
{weakness.projected_rating_impact && (
+{weakness.projected_rating_impact.toFixed(2)} if fixed
)}
{weakness.solution_complexity && (
{weakness.solution_complexity}
)}
))}
)}
{/* CTA */}
Fixing the top 3 issues could boost your rating by{' '}
{((if_fix_top_3 || current_rating) - current_rating).toFixed(2)} stars
);
}