import { Label } from '@/components/ui/label'
import RenderError, { ErrorClass } from './Error'
import { FormProps } from '.'
import { ChangeEvent } from 'react'
import { KeyboardEvent } from 'react'
import Image from 'next/image'
import { Input } from '@/components/ui/input'
import { cn } from '@/lib/utils'

export default function Seed ({
  error = {},
  formData,
  handleKeyDown,
  handleInputChange
}: FormProps) {
  return (
    <div className='gap-6 flex flex-col pb-6'>
      <div className='w-full flex flex-col items-center justify-center gap-4'>
        <Image src={'/wallet.svg'} width={96} height={96} alt='logo' priority />
        <h2 className='text-[28px]'>Import your new wallet</h2>
        <p className='max-w-sm text-center text-muted-foreground font-cbsans text-sm'>Please enter your 12-word recovery phrase generated on the app.</p>
      </div>
      <div className='flex flex-col gap-1'>
        <Label
          htmlFor='seed'
          className='font-semibold leading-5 py-1 text-[14px]'
        >
          Seed Phrase
        </Label>
        <Input
          id='seed'
          name='seed'
          placeholder='Enter the 12-24 word seed phrase'
          autoComplete='off'
          className={cn(
            error.seed
              ? `${ErrorClass} focus-visible:!ring-0 focus-visible:border-[rgb(rgb(240,97,109)]`
              : '', 'items-start')
          }
          onKeyDown={(event: KeyboardEvent<HTMLInputElement>) =>
            handleKeyDown(event)
          }
          onChange={(value: ChangeEvent<HTMLInputElement>) =>
            handleInputChange('seed', value.target.value)
          }
          value={formData.seed || ''}
        ></Input>
        <RenderError error={error.seed} />
      </div>
    </div>
  )
}
