import { type FC, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import Button from "../../../../../components/Button"; import Input from "../../../../../components/Input"; import Select from "../../../../../components/Select"; type Props = { onClose: () => void; onSubmit: (data: { file?: File; title: string; linkId: string }) => void; }; const TaskDetailAttachmentForm: FC = ({ onClose, onSubmit }) => { const { t } = useTranslation("global"); const fileInputRef = useRef(null); const [file, setFile] = useState(null); const [title, setTitle] = useState(""); const [linkId, setLinkId] = useState(""); const linkItems = [{ value: "", label: t("taskmanager.task_detail.none") }]; const canSubmit = Boolean(file) || Boolean(title.trim()); const handleFileChange = (e: React.ChangeEvent) => { const selected = e.target.files?.[0]; if (selected) setFile(selected); }; const handleSubmit = () => { if (!canSubmit) return; onSubmit({ file: file ?? undefined, title: title.trim(), linkId, }); }; return (

{t("taskmanager.task_detail.attachment")}

{file ? file.name : t("no_select_file")}
{t("taskmanager.task_detail.or")}
setTitle(e.target.value)} className="h-8 bg-white/63 border-white" labelClassName="text-xs" />