61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
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>
|
||
);
|
||
}
|