Skip to content

Commit 0c5a1aa

Browse files
fix: build issues (#1067)
Signed-off-by: pranalidhanavade <pranali.dhanavade@ayanworks.com>
1 parent d1775db commit 0c5a1aa

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

nextjs/src/features/passkey/PassKeyAddDevice.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import {
1111
} from '@/components/ui/dialog'
1212
import { Eye, EyeOff } from 'lucide-react'
1313
import { Field, Form, Formik } from 'formik'
14+
import { useEffect, useState } from 'react'
1415

1516
import { AxiosResponse } from 'axios'
1617
import { Button } from '@/components/ui/button'
1718
import { Input } from '@/components/ui/input'
1819
import { addPasskeyUserDetails } from '@/app/api/Fido'
1920
import { apiStatusCodes } from '@/config/CommonConstant'
2021
import { passwordEncryption } from '@/app/api/Auth'
21-
import { useState } from 'react'
2222

2323
interface PasswordValue {
2424
Password: string
@@ -29,7 +29,7 @@ interface PasskeyAddDeviceProps {
2929
setOpenModel: (flag: boolean) => void
3030
closeModal: (flag: boolean) => void
3131
registerWithPasskey: (flag: boolean) => Promise<void>
32-
email: string | undefined
32+
email: string | null
3333
}
3434

3535
export default function PasskeyAddDevice({
@@ -42,10 +42,15 @@ export default function PasskeyAddDevice({
4242
const [success] = useState<string | null>(null)
4343
const [nextStep, setNextStep] = useState(false)
4444
const [passwordVisible, setPasswordVisible] = useState(false)
45+
const [userEmail, setUserEmail] = useState('')
4546

46-
const userEmail = email
4747
const savePassword = async (values: PasswordValue): Promise<void> => {
4848
try {
49+
if (!userEmail) {
50+
setFidoUserError('User email is missing. Please refresh the page.')
51+
return
52+
}
53+
4954
const payload = {
5055
password: passwordEncryption(values.Password),
5156
}
@@ -65,6 +70,12 @@ export default function PasskeyAddDevice({
6570
}
6671
}
6772

73+
useEffect(() => {
74+
if (email) {
75+
setUserEmail(email)
76+
}
77+
}, [email])
78+
6879
return (
6980
<Dialog open={openModal} onOpenChange={setOpenModel}>
7081
<DialogContent>

0 commit comments

Comments
 (0)