import Title from "@/components/Title";
import styles from "./styles.module.css";
import MainButton from "@/components/MainButton";
import { useNavigate } from "react-router-dom";
import routes from "@/routes";
import { useSelector } from "react-redux";
import { selectors } from "@/store";
import { getZodiacSignByDate } from "@/services/zodiac-sign";
import { useDynamicSize } from "@/hooks/useDynamicSize";
import BackgroundTopBlob from "../../ui/BackgroundTopBlob";
import Header from "../../components/Header";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
import { useTranslations } from "@/hooks/translations";
import { ELocalesPlacement } from "@/locales";

function PartnerTotallyNormalPage() {
  const navigate = useNavigate();
  const { translate } = useTranslations(ELocalesPlacement.V1);
  const birthdate = useSelector(selectors.selectBirthdate);
  const zodiacSign = getZodiacSignByDate(birthdate);
  const { width: pageWidth, elementRef: pageRef } = useDynamicSize({});

  const { animationData } = useLottie({
    loadKey: ELottieKeys.cloudAndStars,
    preloadKey: ELottieKeys.scalesHead,
  });
  useLottie({
    preloadKey: ELottieKeys.scalesHeart,
  });

  const handleBack = () => {
    navigate(-1);
  };

  const handleNext = () => {
    navigate(`${routes.client.questionnaireV1()}/relationships/appreciated`);
  };

  return (
    <section className={`${styles.page} page`} ref={pageRef}>
      <BackgroundTopBlob
        width={pageWidth}
        height={388}
        className={styles["background-top-blob"]}
      />
      <Header isBackButtonVisible={false} />
      <div className={styles.circle}>
        {animationData && (
          <DotLottieReact
            className={`${styles["lottie-animation"]} ym-hide-content`}
            data={animationData}
            autoplay
            loop={false}
          />
        )}
      </div>
      <div>
        <Title variant="h1" className={styles.title}>
          {translate("/partner-totally-normal.title", {
            zodiacSign: (
              <span style={{ color: "#A6FD18" }}>
                {translate(`zodiac_signs.${zodiacSign?.toLowerCase()}`)}
              </span>
            ),
          })}
        </Title>
        <p className={styles.text}>{translate("/partner-totally-normal.description")}</p>
      </div>
      <div className={styles["buttons-container"]}>
        <MainButton
          className={`${styles.button} ${styles["back-button"]}`}
          onClick={handleBack}
        >
          {translate("back")}
        </MainButton>
        <MainButton
          className={`${styles.button} ${styles["next-button"]}`}
          onClick={handleNext}
        >
          {translate("next")}
        </MainButton>
      </div>
    </section>
  );
}

export default PartnerTotallyNormalPage;
