aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/src/app/(auth)/login/page.tsx
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswa Kalyan Bhuyan <biswa@surgot.in> 2025-04-24 09:13:07 +0530
committerLibravatarLibravatar Biswa Kalyan Bhuyan <biswa@surgot.in> 2025-04-24 09:13:07 +0530
commitcaace928ac81c284629ee50942d72179d4da9784 (patch)
treeb2f4e87b7a53e30ac5ac9af94cdc70c2da5bbfb9 /frontend/src/app/(auth)/login/page.tsx
parent50d5e6534f5e593297a09323e683c7c8b850117b (diff)
downloadfinance-caace928ac81c284629ee50942d72179d4da9784.tar.gz
finance-caace928ac81c284629ee50942d72179d4da9784.tar.bz2
finance-caace928ac81c284629ee50942d72179d4da9784.zip
feat: Fix loan API type assertion and complete core loan features
- Resolve interface conversion panic in loan handlers by correcting user type assertions from *models.User to models.User - Finalize loan management API integration with frontend components - Implement remaining loan calculation logic and CRUD operations - Connect loan display components to backend APIs as per Phase 3 - Update project status in README.md to reflect completed loan features - Add CORS middleware configuration for frontend-backend communication This commit completes core loan management functionality and fixes critical type safety issues in the API handlers, enabling proper user context handling.
Diffstat (limited to 'frontend/src/app/(auth)/login/page.tsx')
-rw-r--r--frontend/src/app/(auth)/login/page.tsx88
1 files changed, 88 insertions, 0 deletions
diff --git a/frontend/src/app/(auth)/login/page.tsx b/frontend/src/app/(auth)/login/page.tsx
new file mode 100644
index 0000000..7460b8a
--- /dev/null
+++ b/frontend/src/app/(auth)/login/page.tsx
@@ -0,0 +1,88 @@
+'use client';
+
+import { useState, useEffect } from 'react';
+import { useRouter, useSearchParams } from 'next/navigation';
+import Link from 'next/link';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { authApi } from '@/lib/api';
+import { useNotification } from '@/components/shared/NotificationContext';
+
+export default function LoginPage() {
+ const router = useRouter();
+ const searchParams = useSearchParams();
+ const { showNotification } = useNotification();
+ const [email, setEmail] = useState('');
+ const [password, setPassword] = useState('');
+ const [error, setError] = useState('');
+ const [isLoading, setIsLoading] = useState(false);
+
+ useEffect(() => {
+ // Check if the user was redirected from signup
+ if (searchParams.get('signup') === 'success') {
+ showNotification('success', 'Account created successfully! Please log in.');
+ }
+ }, [searchParams, showNotification]);
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+ setError('');
+ setIsLoading(true);
+
+ try {
+ await authApi.login(email, password);
+ showNotification('success', 'Logged in successfully!');
+ router.push('/dashboard');
+ } catch (err: any) {
+ setError(err.message || 'Login failed');
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ return (
+ <div>
+ <form onSubmit={handleSubmit} className="space-y-4">
+ <div className="space-y-2">
+ <Label htmlFor="email">Email</Label>
+ <Input
+ id="email"
+ type="email"
+ placeholder="your@email.com"
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ required
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="password">Password</Label>
+ <Input
+ id="password"
+ type="password"
+ value={password}
+ onChange={(e) => setPassword(e.target.value)}
+ required
+ />
+ </div>
+
+ {error && (
+ <div className="text-sm text-red-500">
+ {error}
+ </div>
+ )}
+
+ <Button type="submit" className="w-full" disabled={isLoading}>
+ {isLoading ? 'Logging in...' : 'Login'}
+ </Button>
+ </form>
+
+ <div className="mt-4 text-center text-sm">
+ Don&apos;t have an account?{' '}
+ <Link href="/signup" className="text-primary underline underline-offset-2">
+ Sign up
+ </Link>
+ </div>
+ </div>
+ );
+} \ No newline at end of file