/** برچسب فارسی امتیاز — بدون وابستگی به کش ترجمه */
const RATING_FA: Record<string, string> = {
  "very.bad": "خیلی بد",
  bad: "بد",
  "not.bad": "متوسط",
  good: "خوب",
  "very.good": "خیلی خوب",
  exceptional: "عالی",
  new: "جدید",
};

export const createRatingText = (review?: number | null) => {
  let key = "new";
  if (typeof review !== "undefined" && review !== null) {
    if (review <= 1) key = "very.bad";
    else if (review <= 2) key = "bad";
    else if (review <= 3) key = "not.bad";
    else if (review <= 4) key = "good";
    else if (review <= 4.5) key = "very.good";
    else if (review <= 5) key = "exceptional";
  }
  return RATING_FA[key] ?? key;
};

/** اگر جایی هنوز کلید خام می‌خواهد */
export const createRatingKey = (review?: number | null) => {
  if (typeof review !== "undefined" && review !== null) {
    if (review <= 1) return "very.bad";
    if (review <= 2) return "bad";
    if (review <= 3) return "not.bad";
    if (review <= 4) return "good";
    if (review <= 4.5) return "very.good";
    if (review <= 5) return "exceptional";
  }
  return "new";
};
