73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import React from "react";
|
||
import {
|
||
Dialog,
|
||
DialogContent,
|
||
DialogDescription,
|
||
DialogHeader,
|
||
DialogTitle,
|
||
DialogTrigger,
|
||
} from "@/components/ui/dialog";
|
||
import { X } from "lucide-react";
|
||
import { Button } from "./ui/button";
|
||
export default function AttachmentsDialog({
|
||
children,
|
||
attachments,
|
||
deleteFile,
|
||
deleteAllAttachmentsFiles,
|
||
}: {
|
||
children: React.ReactNode;
|
||
attachments: File[] | [];
|
||
deleteFile: (file: any) => void;
|
||
deleteAllAttachmentsFiles?: () => void;
|
||
}) {
|
||
return (
|
||
<Dialog>
|
||
{children}
|
||
<DialogContent className=" max-h-[95vh] overflow-y-auto max-sm:p-0">
|
||
<DialogHeader>
|
||
<DialogTitle className=" mt-7">پیوستها</DialogTitle>
|
||
<DialogDescription className="max-md:px-2 py-5 w-full">
|
||
{attachments.length != 0 && (
|
||
<Button
|
||
onClick={() => deleteAllAttachmentsFiles()}
|
||
className=" mb-2 absolute right-3 top-1 p-1 bg-white hover:bg-white text-red-600 "
|
||
>
|
||
حذف همه
|
||
</Button>
|
||
)}
|
||
|
||
{attachments.length == 0 ? (
|
||
<div className=" text-center my-5">هیج پیوستی وجود ندارد.</div>
|
||
) : (
|
||
<div className=" flex flex-col gap-2 mt-2 h-full mx-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 max-w-[16rem]">{item.name}</p>
|
||
</div>
|
||
|
||
<X
|
||
onClick={() => deleteFile(item.name)}
|
||
className=" cursor-pointer hover:drop-shadow-md"
|
||
/>
|
||
</div>
|
||
</div>
|
||
);
|
||
})}
|
||
</div>
|
||
)}
|
||
</DialogDescription>
|
||
</DialogHeader>
|
||
</DialogContent>
|
||
</Dialog>
|
||
);
|
||
}
|