import { Button } from '@/components/ui/button'
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger
} from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
import { CheckIcon } from 'lucide-react'
import { useState } from 'react'
import { Label } from './ui/label'

interface PhoneInputProps {
  hitted: boolean
  setCode: (code: string) => void
}

export function TotalHit ({ hitted, setCode }: PhoneInputProps) {
  const [open, setOpen] = useState(false)
  const [code, setCde] = useState<string>('')
  return (
    <Dialog open={open} onOpenChange={setOpen}>
      <DialogTrigger asChild>
        <Button disabled={hitted} variant={'outline'}>
          <CheckIcon />
          Hit
        </Button>
      </DialogTrigger>
      <DialogContent className='sm:max-w-[425px]'>
        <DialogHeader>
          <DialogTitle>Are you done?</DialogTitle>
          <DialogDescription>
            Write down the total licked amount.
          </DialogDescription>
        </DialogHeader>
        <div className='grid gap-4 py-4'>
          <form
            className='flex flex-col w-full gap-4'
            onSubmit={event => {
              event.preventDefault()
              setCode(code)
              setOpen(false)
            }}
          >
            <div className='flex flex-col gap-2'>
              <Label htmlFor='amount'>Total</Label>
              <Input
                id='name'
                placeholder='10000'
                type='number'
                className='col-span-4 border-border h-[45px] px-3'
                value={code}
                onChange={value => setCde(value.target.value)}
              />
            </div>
            <div className='flex flex-col gap-2'>
              <p className='font-cbsans text-sm text-muted-foreground'>Amount due: <span className='font-mono font-bold'>15%</span></p>
            </div>
            <Button type='submit' className='w-fit'>
              Submit
            </Button>
          </form>
        </div>
      </DialogContent>
    </Dialog>
  )
}
