prefilled did
This commit is contained in:
@@ -2,30 +2,25 @@ import {StatusOfflineIcon} from '@heroicons/react/solid'
|
||||
import type {SubmitHandler} from 'react-hook-form'
|
||||
import {useForm} from 'react-hook-form'
|
||||
import {usePrivy, useSignMessage} from '@privy-io/react-auth'
|
||||
import {useEffect} from 'react'
|
||||
|
||||
import useApiUrlStore from '../../../app/store/apiStore'
|
||||
import {UserClient} from '../../../generated/ManagingApi'
|
||||
import type {ILoginFormInput} from '../../../global/type'
|
||||
import type {ILoginFormInput} from '../../../global/type.tsx'
|
||||
import useCookie from '../../../hooks/useCookie'
|
||||
import {SecondaryNavbar} from '../NavBar/NavBar'
|
||||
import Toast from '../Toast/Toast'
|
||||
|
||||
const LogIn = () => {
|
||||
const { apiUrl } = useApiUrlStore()
|
||||
const { register, handleSubmit, setValue } = useForm<ILoginFormInput>()
|
||||
const { user, logout, ready, authenticated } = usePrivy()
|
||||
const { signMessage } = useSignMessage()
|
||||
const { setCookie } = useCookie()
|
||||
|
||||
// Prefill the name field with the Privy DID when user is available
|
||||
useEffect(() => {
|
||||
if (user?.id) {
|
||||
console.log(user)
|
||||
|
||||
setValue('name', user.id)
|
||||
const { register, handleSubmit } = useForm<ILoginFormInput>({
|
||||
defaultValues: {
|
||||
name: user?.id || ''
|
||||
}
|
||||
}, [user?.id, setValue])
|
||||
})
|
||||
|
||||
const onSubmit: SubmitHandler<ILoginFormInput> = async (form) => {
|
||||
if (!authenticated || !user || !user.wallet?.address) {
|
||||
@@ -116,6 +111,7 @@ const LogIn = () => {
|
||||
<input
|
||||
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
{...register('name')}
|
||||
disabled={true}
|
||||
></input>
|
||||
</div>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user