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 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 RelationshipAlmostTherePage() {
  const { translate } = useTranslations(ELocalesPlacement.V1);
  const navigate = useNavigate();

  const { animationData } = useLottie({
    loadKey: ELottieKeys.magnifyingGlassAndPlanet,
    preloadKey: ELottieKeys.sun,
  });

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

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

  return (
    <section className={`${styles.page} page`}>
      <div className={styles["background_wrap"]} />
      <Header
        classNameTitle={styles["header-title"]}
        isBackButtonVisible={false}
      />
      <div className={`${styles["lottie-animation"]} ym-hide-content`}>
        {animationData && (
          <DotLottieReact data={animationData} autoplay loop={false} />
        )}
      </div>
      <div>
        <Title variant="h1" className={styles.title}>
          {translate("/relationship-almost-there.title", {
            almostThere: (
              <strong>{translate("/relationship-almost-there.almost_there")}</strong>
            ),
            titleGradient: (
              <span className={styles.gradient}>
                {translate("/relationship-almost-there.title_gradient")}
              </span>
            ),
          })}
        </Title>
        <p className={styles.text}>
          {translate("/relationship-almost-there.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 RelationshipAlmostTherePage;
