1f8d44ebfe
CI/CD - Build & Test / Backend Tests (push) Has been cancelled
CI/CD - Build & Test / Frontend Tests (push) Has been cancelled
CI/CD - Build & Test / Security Scans (push) Has been cancelled
CI/CD - Build & Test / Docker Build Test (push) Has been cancelled
CI/CD - Build & Test / Terraform Validate (push) Has been cancelled
Deploy to Production / Build & Test (push) Has been cancelled
Deploy to Production / Security Scan (push) Has been cancelled
Deploy to Production / Build Docker Images (push) Has been cancelled
Deploy to Production / Deploy to Staging (push) Has been cancelled
Deploy to Production / E2E Tests (push) Has been cancelled
Deploy to Production / Deploy to Production (push) Has been cancelled
E2E Tests / Run E2E Tests (push) Has been cancelled
E2E Tests / Visual Regression Tests (push) Has been cancelled
E2E Tests / Smoke Tests (push) Has been cancelled
- Add ForgotPassword page with email submission form - Add ResetPassword page with token validation and new password form - Extend AuthContext with requestPasswordReset and resetPassword functions - Add routes for /forgot-password and /reset-password in App.tsx - Update Login page to link to forgot password flow instead of showing alert Implements Fase 1 of frontend missing features analysis
110 lines
3.8 KiB
TypeScript
110 lines
3.8 KiB
TypeScript
import { useState } from 'react';
|
|
import { Link, useNavigate } from 'react-router-dom';
|
|
import { useAuth } from '@/contexts/AuthContext';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Input } from '@/components/ui/input';
|
|
import { Label } from '@/components/ui/label';
|
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
|
|
import { Cloud, Loader2 } from 'lucide-react';
|
|
|
|
export function Login() {
|
|
const [email, setEmail] = useState('');
|
|
const [password, setPassword] = useState('');
|
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
const { login } = useAuth();
|
|
const navigate = useNavigate();
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
setIsSubmitting(true);
|
|
|
|
const success = await login(email, password);
|
|
if (success) {
|
|
navigate('/');
|
|
}
|
|
|
|
setIsSubmitting(false);
|
|
};
|
|
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-muted/50 p-4">
|
|
<div className="w-full max-w-md">
|
|
<div className="flex items-center justify-center gap-2 mb-8">
|
|
<Cloud className="h-8 w-8 text-primary" />
|
|
<span className="text-2xl font-bold">mockupAWS</span>
|
|
</div>
|
|
|
|
<Card>
|
|
<CardHeader className="space-y-1">
|
|
<CardTitle className="text-2xl text-center">Sign in</CardTitle>
|
|
<CardDescription className="text-center">
|
|
Enter your credentials to access your account
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<form onSubmit={handleSubmit}>
|
|
<CardContent className="space-y-4">
|
|
<div className="space-y-2">
|
|
<Label htmlFor="email">Email</Label>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
placeholder="name@example.com"
|
|
value={email}
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
required
|
|
autoComplete="email"
|
|
/>
|
|
</div>
|
|
<div className="space-y-2">
|
|
<div className="flex items-center justify-between">
|
|
<Label htmlFor="password">Password</Label>
|
|
<Link
|
|
to="/forgot-password"
|
|
className="text-sm text-primary hover:underline"
|
|
>
|
|
Forgot password?
|
|
</Link>
|
|
</div>
|
|
<Input
|
|
id="password"
|
|
type="password"
|
|
placeholder="••••••••"
|
|
value={password}
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
required
|
|
autoComplete="current-password"
|
|
/>
|
|
</div>
|
|
</CardContent>
|
|
<CardFooter className="flex flex-col space-y-4">
|
|
<Button
|
|
type="submit"
|
|
className="w-full"
|
|
disabled={isSubmitting}
|
|
>
|
|
{isSubmitting ? (
|
|
<>
|
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
Signing in...
|
|
</>
|
|
) : (
|
|
'Sign in'
|
|
)}
|
|
</Button>
|
|
<p className="text-sm text-center text-muted-foreground">
|
|
Don't have an account?{' '}
|
|
<Link to="/register" className="text-primary hover:underline">
|
|
Create account
|
|
</Link>
|
|
</p>
|
|
</CardFooter>
|
|
</form>
|
|
</Card>
|
|
|
|
<p className="text-center text-sm text-muted-foreground mt-8">
|
|
AWS Cost Simulator & Backend Profiler
|
|
</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
} |