import { isSigninEnabledForProvider } from '@documenso/lib/constants/auth';
import { Button } from '@documenso/ui/primitives/button';
import { msg } from '@lingui/core/macro';
import { Trans } from '@lingui/react/macro';
import { Link, redirect } from 'react-router';

import { appMetaTags } from '~/utils/meta';

export function meta() {
  return appMetaTags(msg`Reset Password`);
}

export async function loader() {
  if (!isSigninEnabledForProvider('email')) {
    throw redirect('/signin');
  }

  return null;
}

export default function ResetPasswordPage() {
  return (
    <div className="w-screen max-w-lg px-4">
      <div className="w-full">
        <h1 className="font-semibold text-3xl">
          <Trans>Unable to reset password</Trans>
        </h1>

        <p className="mt-2 text-muted-foreground text-sm">
          <Trans>
            The token you have used to reset your password is either expired or it never existed. If you have still
            forgotten your password, please request a new reset link.
          </Trans>
        </p>

        <Button className="mt-4" asChild>
          <Link to="/signin">
            <Trans>Return to sign in</Trans>
          </Link>
        </Button>
      </div>
    </div>
  );
}
