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 { selectors } from "@/store";
import { useSelector } from "react-redux";
import { getZodiacSignByDate } from "@/services/zodiac-sign";
import Header from "../../components/Header";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
import { ELottieKeys, useLottie } from "@/hooks/lottie/useLottie";
import { useTranslations } from "@/hooks/translations";
import { ELocalesPlacement } from "@/locales";

function NotAlonePage() {
  const navigate = useNavigate();
  const { translate } = useTranslations(ELocalesPlacement.V1);
  const { birthdate } = useSelector(selectors.selectQuestionnaire);
  const zodiacSign = getZodiacSignByDate(birthdate);

  const { animationData } = useLottie({
    loadKey: ELottieKeys.umbrella,
  });

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

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

  return (
    <section className={`${styles.page} page`}>
      <div className={styles["background_wrap"]} />
      <Header
        isBackButtonVisible={false}
        classNameTitle={styles["header-title"]}
      />
      <div className={`${styles["lottie-animation"]} ym-hide-content`}>
        {animationData && (
          <DotLottieReact data={animationData} autoplay loop={false} />
        )}
      </div>
      <div>
        <Title variant="h1" className={styles.title}>
          {translate("/not-alone.title")}
        </Title>
        <p className={styles.text}>
          {translate("/not-alone.description", {
            zodiacSign: (
              <span style={{ color: "#f2c94c" }}>
                {translate(`zodiac_signs.${zodiacSign?.toLowerCase()}`)}
              </span>
            ),
          })}
        </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 NotAlonePage;
