import Link from "next/link";
import { useRouter } from "next/router";
import { useTranslation } from "~/providers/I18nProvider";
import { HomeIcon } from "~/components/IconComponents";
import { ASvg } from "~/components/svgs";

export const LoadingPage = () => {
  return (
    <div className="flex h-full max-h-full w-full animate-pulse items-center justify-center py-20">
      <div className="relative flex size-40 animate-spin items-center justify-center rounded-full border-8 border-gray-300 border-t-red-400 text-4xl text-red-400"></div>
      <ASvg className="absolute size-24 -translate-y-2" />
    </div>
  );
};

export default function FailedAnnuncioLoading() {
  const router = useRouter();
  const { t } = useTranslation();
  return (
    <main>
      <div className="mx-auto flex h-screen max-w-screen-xl items-center justify-start px-4 md:px-8">
        <div className="mx-auto max-w-lg space-y-3 text-center">
          <HomeIcon className="mx-auto size-20 text-rose-700" />
          <h3 className="text-accent-foreground text-4xl font-semibold sm:text-5xl">
            {t.annuncio_load_fail.titolo}
          </h3>
          <p className="text-neutral-600">{t.annuncio_load_fail.sottotitolo}</p>
          <div className="flex flex-wrap items-center justify-center gap-3">
            <button
              onClick={() => {
                router.back();
              }}
              className="block rounded-lg bg-rose-600 px-4 py-2 font-medium text-white duration-150 hover:bg-rose-500 active:bg-rose-700"
            >
              {t.annuncio_load_fail.CTA}
            </button>
            <Link
              href="/annunci"
              className="block rounded-lg border px-4 py-2 font-medium text-neutral-700 duration-150 hover:bg-neutral-50 active:bg-neutral-100"
            >
              {t.annuncio_load_fail.home}
            </Link>
          </div>
        </div>
      </div>
    </main>
  );
}
