"use client"

import { FC, ChangeEvent } from "react"
import { Paperclip, CheckCircle } from "lucide-react"

interface AttachmentInputProps  {
  fileName?: string | null
  hasFile?: boolean
  accept?: string
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void
}

const AttachmentInput: FC<AttachmentInputProps > = ({
  fileName,
  hasFile,
  accept,
  onChange,
}) => {
  return (
    <label
      className="
        flex items-center justify-between
        h-12
        w-full

        border border-dashed border-input
        rounded-xl
        px-4

        bg-white dark:bg-input
        shadow-sm

        cursor-pointer
        transition
        hover:bg-muted/40
      "
    >
      <div className="flex items-center">
        <div className="p-2 rounded-md bg-primary/10">
          <Paperclip className="w-4 h-4 text-primary" />
        </div>

        <span className="mr-2 text-sm text-muted-foreground">
          {fileName
            ? "فایل پیوست انتخاب شد"
            : "برای بارگذاری فایل اینجا کلیک کنید"}
        </span>
      </div>

      {hasFile && (
        <CheckCircle className="mr-2 w-5 h-5 text-green-500" />
      )}

      <input
        type="file"
        className="hidden"
        accept={accept}
        onChange={onChange}
      />
    </label>
  )
}

export default AttachmentInput
