feat: update login role from admin to agent and include loginRole in authentication request

This commit is contained in:
pradeepkumar
2026-04-13 20:27:02 +05:30
parent 580415f98a
commit 081dd65f1e

View File

@@ -14,7 +14,7 @@ export default function LoginPage() {
const [showPassword, setShowPassword] = useState(false); const [showPassword, setShowPassword] = useState(false);
const [error, setError] = useState(''); const [error, setError] = useState('');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [userType, setUserType] = useState<'USER' | 'ADMIN'>('USER'); const [userType, setUserType] = useState<'USER' | 'AGENT'>('USER');
const [showResendVerification, setShowResendVerification] = useState(false); const [showResendVerification, setShowResendVerification] = useState(false);
const [resendingVerification, setResendingVerification] = useState(false); const [resendingVerification, setResendingVerification] = useState(false);
const [resendSuccess, setResendSuccess] = useState(''); const [resendSuccess, setResendSuccess] = useState('');
@@ -74,7 +74,7 @@ export default function LoginPage() {
const validateRes = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/login`, { const validateRes = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/login`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }), body: JSON.stringify({ email, password, loginRole: userType }),
}); });
const validateData = await validateRes.json(); const validateData = await validateRes.json();
@@ -164,14 +164,14 @@ export default function LoginPage() {
</button> </button>
<button <button
type="button" type="button"
onClick={() => setUserType('ADMIN')} onClick={() => setUserType('AGENT')}
className={`px-10 py-2 text-[14px] font-semibold rounded-[15px] transition-all duration-200 font-serif ${ className={`px-10 py-2 text-[14px] font-semibold rounded-[15px] transition-all duration-200 font-serif ${
userType === 'ADMIN' userType === 'AGENT'
? 'bg-[#00293d] text-[#f0f5fc] border border-[#00293d]' ? 'bg-[#00293d] text-[#f0f5fc] border border-[#00293d]'
: 'text-[#00293d]' : 'text-[#00293d]'
}`} }`}
> >
Admin Agent
</button> </button>
</div> </div>
</div> </div>