diff --git a/src/app/(auth)/signup/page.tsx b/src/app/(auth)/signup/page.tsx index 10514ff..03b3b85 100644 --- a/src/app/(auth)/signup/page.tsx +++ b/src/app/(auth)/signup/page.tsx @@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'; import { signIn } from 'next-auth/react'; +import { useSearchParams } from 'next/navigation'; import Link from 'next/link'; import { authService, AuthService, RegisterRequest, agentsService, AgentType } from '@/services'; import { resetLogoutState } from '@/services/api'; @@ -14,6 +15,7 @@ interface ValidationError { } export default function SignUpPage() { + const searchParams = useSearchParams(); const [userType, setUserType] = useState('USER'); const [firstName, setFirstName] = useState(''); const [lastName, setLastName] = useState(''); @@ -28,6 +30,14 @@ export default function SignUpPage() { const [selectedAgentTypeId, setSelectedAgentTypeId] = useState(''); const [loadingAgentTypes, setLoadingAgentTypes] = useState(false); + // Surface errors passed via ?error= (e.g. from social signup callback) + useEffect(() => { + const errorParam = searchParams.get('error'); + if (errorParam) { + setError(decodeURIComponent(errorParam)); + } + }, [searchParams]); + // Clear logout flags and fetch agent types on mount useEffect(() => { localStorage.removeItem('isLoggingOut'); diff --git a/src/auth.ts b/src/auth.ts index 3289c95..15bc8ea 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -155,7 +155,8 @@ export const { handlers, signIn, signOut, auth } = NextAuth({ (user as any).refreshToken = data.data.refreshToken; } else if (!res.ok) { const errorMsg = data?.message || "Social login failed"; - return `/login?error=${encodeURIComponent(errorMsg)}`; + const returnTo = mode === 'signup' ? '/signup' : '/login'; + return `${returnTo}?error=${encodeURIComponent(errorMsg)}`; } } catch (error) { console.error("Social auth sync error:", error); diff --git a/src/components/profiles/FilterModal.tsx b/src/components/profiles/FilterModal.tsx index 9827ba5..89a87d0 100644 --- a/src/components/profiles/FilterModal.tsx +++ b/src/components/profiles/FilterModal.tsx @@ -103,16 +103,16 @@ export function FilterModal({ isOpen, onClose, filters, filterFields, onToggleFi {/* Footer */} -
+