diff options
author | 2025-04-25 01:09:30 +0530 | |
---|---|---|
committer | 2025-04-25 01:09:30 +0530 | |
commit | 8733795c8449f3514369d7b4220934760e386f1b (patch) | |
tree | 86b70bd897f22646df401f5e24e28bb35f3ca155 /frontend/src/app/(auth)/signup/page.tsx | |
parent | 4cd8498ad30e6ea5f01e81346a81a2a1134864be (diff) | |
download | finance-8733795c8449f3514369d7b4220934760e386f1b.tar.gz finance-8733795c8449f3514369d7b4220934760e386f1b.tar.bz2 finance-8733795c8449f3514369d7b4220934760e386f1b.zip |
finance/frontend: fix: did some minor changes to the frontend
Diffstat (limited to 'frontend/src/app/(auth)/signup/page.tsx')
-rw-r--r-- | frontend/src/app/(auth)/signup/page.tsx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/frontend/src/app/(auth)/signup/page.tsx b/frontend/src/app/(auth)/signup/page.tsx index af25031..cd9daab 100644 --- a/frontend/src/app/(auth)/signup/page.tsx +++ b/frontend/src/app/(auth)/signup/page.tsx @@ -1,17 +1,18 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect } 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 { useAuth } from '@/components/shared/AuthContext'; import { useNotification } from '@/components/shared/NotificationContext'; export default function SignupPage() { const router = useRouter(); const { showNotification } = useNotification(); + const { signup, isAuthenticated } = useAuth(); const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); @@ -19,6 +20,13 @@ export default function SignupPage() { const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); + useEffect(() => { + // Redirect if already authenticated + if (isAuthenticated) { + router.push('/dashboard'); + } + }, [isAuthenticated, router]); + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); @@ -32,9 +40,9 @@ export default function SignupPage() { setIsLoading(true); try { - await authApi.signup(name, email, password); + await signup(name, email, password); // Show success notification - showNotification('success', `Your email ${email} has been successfully registered!`); + showNotification('success', `Welcome to Finance Management, ${name}! Your account has been successfully created.`); // Redirect to login after successful signup with a slight delay to see the notification setTimeout(() => { router.push('/login?signup=success'); |