'use client'

import { TextField } from '@mui/material'
import { StyledInputs } from './mui/styled-inputs'
import {
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from './ui/alert-dialog'
import { Button } from './ui/button'

type AlertDialogProps = {
  title: string
  description: string
  value?: string
  handleClick: () => void
  handleClickDelete?: () => void
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
}

export default function ModalInputs({
  title,
  description,
  value,
  handleClick,
  handleClickDelete,
  onChange,
}: AlertDialogProps) {

  return (
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogTitle>{title}</AlertDialogTitle>
        <AlertDialogDescription>{description}</AlertDialogDescription>
      </AlertDialogHeader>
      <TextField
        label="Nome"
        type="text"
        value={value}
        onChange={onChange}
        variant="standard"
        className="flex"
        sx={StyledInputs({ color: '#26AAA7' })}
      />
      <AlertDialogFooter className="mt-4 w-full flex !justify-between">
      {handleClickDelete && (
        <Button
          onClick={handleClickDelete}
          variant="outline"
          className="text-gray-50 bg-red-500 hover:bg-red-500/80"
        >
          Deletar
        </Button>
         )}
        <div className='flex gap-4'>
          <AlertDialogCancel>Cancelar</AlertDialogCancel>
          <Button
            onClick={handleClick}
            variant="outline"
            className="text-gray-50 bg-green-500 hover:bg-green-500/80"
          >
            Salvar
          </Button>
        </div>
      </AlertDialogFooter>
    </AlertDialogContent>
  )
}
