import routes from "@/routes";
import styles from "./styles.module.scss";
import Title from "@/components/Title";
import Button from "../../components/Button";
import Policy from "@/components/Policy";
import { useTranslations } from "@/hooks/translations";
import { useNavigate } from "react-router-dom";
import { ELocalesPlacement } from "@/locales";
import { selectors } from "@/store";
import { useSelector } from "react-redux";
import { getZodiacSignByDate } from "@/services/zodiac-sign";

function PalmsInformation() {
  const { translate } = useTranslations(ELocalesPlacement.CompatibilityV4);
  const { relationshipStatus } = useSelector(selectors.selectCompatibilityV4Answers);
  const { gender, birthdate } = useSelector(selectors.selectQuestionnaire);
  const zodiacSign = getZodiacSignByDate(birthdate);
  const navigate = useNavigate();
  const isSingle = relationshipStatus === "single";

  const handleNext = () => {
    if (isSingle) return navigate(routes.client.compatibilityV4Review());
    navigate(routes.client.compatibilityV4ResultAnalysis());
  };

  return (
    <div className={styles["page-container"]}>
      <div className={styles.zodiac}>
        <img
          className={styles.image}
          src={`/zodiac-signs/${gender?.toLowerCase()}/${zodiacSign?.toLowerCase()}.svg`}
          alt="Zodiac sign"
        />
      </div>
      <Title variant="h2" className={styles.title}>
        {translate(`/palms-information.${zodiacSign?.toLowerCase()}.title`)}
      </Title>
      <p className={styles.description}>
        {translate(`/palms-information.${zodiacSign?.toLowerCase()}.description`, {
          br: <br />,
          bold: <b>{translate(`/palms-information.${zodiacSign?.toLowerCase()}.description_bold`)}</b>,
          percent: <b>{translate(`/palms-information.${zodiacSign?.toLowerCase()}.description_percent`)}</b>,
          zodiac: <b>{translate(`zodiac_signs.${zodiacSign?.toLowerCase()}`)}</b>,
        })}
      </p>
      <Button onClick={handleNext}>
        {translate("next")}
      </Button>
      <Policy>
        {translate("privacy_policy", {
          eulaLink: (
            <a
              href="https://aura.wit.life/terms"
              target="_blank"
              rel="noopener noreferrer"
            >
              {translate("eula_link")}
            </a>
          ),
          privacyLink: (
            <a
              href="https://aura.wit.life/privacy"
              target="_blank"
              rel="noopener noreferrer"
            >
              {translate("privacy_notice")}
            </a>
          ),
          clickHere: (
            <a
              href="https://aura.wit.life/"
              target="_blank"
              rel="noopener noreferrer"
            >
              {translate("policy_here")}
            </a>
          ),
        })}
      </Policy>
    </div>
  );
}

export default PalmsInformation;
