From caace928ac81c284629ee50942d72179d4da9784 Mon Sep 17 00:00:00 2001 From: Biswa Kalyan Bhuyan Date: Thu, 24 Apr 2025 09:13:07 +0530 Subject: 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. --- frontend/src/app/(auth)/signup/page.tsx | 116 ++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 frontend/src/app/(auth)/signup/page.tsx (limited to 'frontend/src/app/(auth)/signup') diff --git a/frontend/src/app/(auth)/signup/page.tsx b/frontend/src/app/(auth)/signup/page.tsx new file mode 100644 index 0000000..af25031 --- /dev/null +++ b/frontend/src/app/(auth)/signup/page.tsx @@ -0,0 +1,116 @@ +'use client'; + +import { useState } from 'react'; +import { useRouter } 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 SignupPage() { + const router = useRouter(); + const { showNotification } = useNotification(); + const [name, setName] = useState(''); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [error, setError] = useState(''); + const [isLoading, setIsLoading] = useState(false); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setError(''); + + // Validate passwords match + if (password !== confirmPassword) { + setError('Passwords do not match'); + return; + } + + setIsLoading(true); + + try { + await authApi.signup(name, email, password); + // Show success notification + showNotification('success', `Your email ${email} has been successfully registered!`); + // Redirect to login after successful signup with a slight delay to see the notification + setTimeout(() => { + router.push('/login?signup=success'); + }, 1500); + } catch (err: any) { + setError(err.message || 'Signup failed'); + } finally { + setIsLoading(false); + } + }; + + return ( +
+
+
+ + setName(e.target.value)} + required + /> +
+ +
+ + setEmail(e.target.value)} + required + /> +
+ +
+ + setPassword(e.target.value)} + required + /> +
+ +
+ + setConfirmPassword(e.target.value)} + required + /> +
+ + {error && ( +
+ {error} +
+ )} + + +
+ +
+ Already have an account?{' '} + + Login + +
+
+ ); +} \ No newline at end of file -- cgit v1.2.3-59-g8ed1b