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 type {SubmitHandler} from 'react-hook-form'
|
||||||
import {useForm} from 'react-hook-form'
|
import {useForm} from 'react-hook-form'
|
||||||
import {usePrivy, useSignMessage} from '@privy-io/react-auth'
|
import {usePrivy, useSignMessage} from '@privy-io/react-auth'
|
||||||
import {useEffect} from 'react'
|
|
||||||
|
|
||||||
import useApiUrlStore from '../../../app/store/apiStore'
|
import useApiUrlStore from '../../../app/store/apiStore'
|
||||||
import {UserClient} from '../../../generated/ManagingApi'
|
import {UserClient} from '../../../generated/ManagingApi'
|
||||||
import type {ILoginFormInput} from '../../../global/type'
|
import type {ILoginFormInput} from '../../../global/type.tsx'
|
||||||
import useCookie from '../../../hooks/useCookie'
|
import useCookie from '../../../hooks/useCookie'
|
||||||
import {SecondaryNavbar} from '../NavBar/NavBar'
|
import {SecondaryNavbar} from '../NavBar/NavBar'
|
||||||
import Toast from '../Toast/Toast'
|
import Toast from '../Toast/Toast'
|
||||||
|
|
||||||
const LogIn = () => {
|
const LogIn = () => {
|
||||||
const { apiUrl } = useApiUrlStore()
|
const { apiUrl } = useApiUrlStore()
|
||||||
const { register, handleSubmit, setValue } = useForm<ILoginFormInput>()
|
|
||||||
const { user, logout, ready, authenticated } = usePrivy()
|
const { user, logout, ready, authenticated } = usePrivy()
|
||||||
const { signMessage } = useSignMessage()
|
const { signMessage } = useSignMessage()
|
||||||
const { setCookie } = useCookie()
|
const { setCookie } = useCookie()
|
||||||
|
|
||||||
// Prefill the name field with the Privy DID when user is available
|
const { register, handleSubmit } = useForm<ILoginFormInput>({
|
||||||
useEffect(() => {
|
defaultValues: {
|
||||||
if (user?.id) {
|
name: user?.id || ''
|
||||||
console.log(user)
|
|
||||||
|
|
||||||
setValue('name', user.id)
|
|
||||||
}
|
}
|
||||||
}, [user?.id, setValue])
|
})
|
||||||
|
|
||||||
const onSubmit: SubmitHandler<ILoginFormInput> = async (form) => {
|
const onSubmit: SubmitHandler<ILoginFormInput> = async (form) => {
|
||||||
if (!authenticated || !user || !user.wallet?.address) {
|
if (!authenticated || !user || !user.wallet?.address) {
|
||||||
@@ -116,6 +111,7 @@ const LogIn = () => {
|
|||||||
<input
|
<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"
|
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')}
|
{...register('name')}
|
||||||
|
disabled={true}
|
||||||
></input>
|
></input>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user