Sootzani-Inspector/components/AttachmentsDialog.tsx

61 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import React from "react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { X } from "lucide-react";
export default function AttachmentsDialog({
children,
attachments,
deleteFile,
}: {
children: React.ReactNode;
attachments: File[] | [];
deleteFile: (file: any) => void;
}) {
return (
<Dialog>
{children}
<DialogContent>
<DialogHeader>
<DialogTitle>پیوست‌ها</DialogTitle>
<DialogDescription>
{attachments.length == 0 ? (
<div className=" text-center my-5">هیج پیوستی وجود ندارد.</div>
) : (
<div className=" flex flex-col gap-2 mt-2">
{attachments?.map((item, index) => {
return (
<div
key={index}
className=" flex gap-2 w-full items-center"
>
<div className=" p-2 bg-blue w-10 grid place-content-center rounded-lg text-white">
{index + 1}
</div>
<div className="bg-gray-200 p-2 rounded-lg max-w-full justify-between flex flex-1">
<div className="">
<p className=" truncate">{item.name}</p>
</div>
<X
onClick={() => deleteFile(item.name)}
className=" cursor-pointer hover:drop-shadow-md"
/>
</div>
</div>
);
})}
</div>
)}
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>
);
}