"use client";

import { useTranslation } from "react-i18next";
import Title from "@/components/shared/Title";
import ProfileStatCard from "./ProfileStatCard";
import {
  asset,
  convertDecimalHoursToDisplay,
} from "./volunteerProfileDisplay";

/* The row height the volunteer profile's counters use. */
const CARD_HEIGHT =
  "xl:h-[210px] lg:h-[195px] md:h-[210px] msscreen1:h-[190px] miniscreen10:h-[190px]";

/** Hours and opportunities beside the "about me" — no certificates counter (BA page 25). */
export default function VolunteerBackgroundStats({
  stats,
}: {
  /* Each one is `?? 0`-defaulted by the caller, so none is optional here. */
  stats: {
    volunteerHours: number | string;
    volunteerOpportunities: number | string;
  };
}) {
  const { t } = useTranslation();

  return (
      <div className="2xl:w-[50%] laptopmain:w-1/2 w-full">
        <h2 className="text-start flex">
          <Title text={t("COMMON.ACHIEVEMENT")} variant="default" />
        </h2>

        <div className="grid 2xl:grid-cols-3 xl:grid-cols-3 lg:grid-cols-2 md:grid-cols-3 mobilescreen:grid-cols-1 gap-[30px] mobilescreen:gap-5">
          <ProfileStatCard
            heightClass={CARD_HEIGHT}
            icon={asset("profile/statistics/n_Volunteerhours.svg")}
            alt=""
            value={convertDecimalHoursToDisplay(stats.volunteerHours)}
            label={t("COMMON.VOLUNTEER_HOURS-")}
            color="hours"
          />
          <ProfileStatCard
            heightClass={CARD_HEIGHT}
            icon={asset("profile/statistics/n_VolunteerOpportunities.svg")}
            alt=""
            value={stats.volunteerOpportunities}
            label={t("COMMON.VOLUNTEER_OPPORTUNITIES-")}
            color="opportunities"
          />
        </div>
      </div>
  );
}
