/**
 * Login page.
 *
 * ⚠️ AUTO-GENERATED BY PRISM - DO NOT EDIT
 */

import React from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { LoginForm } from '../components/auth/LoginForm';

/**
 * Login page with form and navigation.
 */
export function Login(): JSX.Element {
  const navigate = useNavigate();
  const location = useLocation();

  // Get the page user was trying to access before login
  const from = (location.state as any)?.from?.pathname || '/';

  const handleSuccess = () => {
    navigate(from, { replace: true });
  };

  const handleSignupClick = () => {
    navigate('/signup');
  };
{% if password_reset %}

  const handleForgotPasswordClick = () => {
    navigate('/forgot-password');
  };
{% endif %}

  return (
    <div className="min-h-screen bg-nordic-50 flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
      <LoginForm
        onSuccess={handleSuccess}
        onSignupClick={handleSignupClick}
{% if password_reset %}
        onForgotPasswordClick={handleForgotPasswordClick}
{% endif %}
      />
    </div>
  );
}
