"use client";

import { useTranslation } from "@enode/core/translations/hooks";
import { YourWeekSheet } from "./your-week-sheet";

// "How to read this": what the numbers on "Your week" are, in plain words.
// Each paragraph is shown only for a part the card itself shows.

export function HowToReadSheet({
  open,
  onClose,
  readiness,
  load,
  sharedWithCoach,
}: {
  open: boolean;
  onClose: () => void;
  /** Whether the card shows the readiness part. */
  readiness: boolean;
  /** Whether the card shows the training-load part. */
  load: boolean;
  sharedWithCoach: boolean;
}) {
  const { t } = useTranslation();
  return (
    <YourWeekSheet open={open} onClose={onClose} title={t("How to read this")}>
      <div className="flex flex-col gap-5">
        {readiness && (
          <>
            <Topic
              title={t("Your score")}
              text={t(
                "The check-in asks five questions. Each answer is 1 to 5, and 5 is always the good end. Added up, they are your score for the day: 5 to 25.",
              )}
            />
            <Topic
              title={t("Your normal")}
              text={t(
                "Your own average over the last four weeks. It takes seven check-ins before there is one. There is no fixed cut-off for a good or a bad day — you are only ever compared with yourself.",
              )}
            />
          </>
        )}
        {load && (
          <Topic
            title={t("Training load")}
            text={t(
              "How hard you rated a session, times the work you recorded in it. The bar shows this week so far against your usual week.",
            )}
          />
        )}
        {sharedWithCoach && (
          <Topic
            title={t("What your coach sees")}
            text={t(
              "The same numbers you see here — nothing more and nothing different.",
            )}
          />
        )}
      </div>
    </YourWeekSheet>
  );
}

function Topic({ title, text }: { title: string; text: string }) {
  return (
    <section className="flex flex-col gap-1">
      <h2 className="body-prominent text-foreground-default">{title}</h2>
      <p className="body-normal text-foreground-muted">{text}</p>
    </section>
  );
}
