mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
20e7dc68e6
* style: update modals typography, alignment * style: made the modal separator full width * style: delete modals consistency * style: update the remaining delete modals * chore: delete modal secondary button text * style: update the remaining create modals * chore: update cancel button text * chore: created modal core * style: modals responsiveness
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { FC, useState } from "react";
|
|
import type { TIssueAttachment } from "@plane/types";
|
|
// components
|
|
import { AlertModalCore } from "@/components/core";
|
|
// helper
|
|
import { getFileName } from "@/helpers/attachment.helper";
|
|
// types
|
|
import { TAttachmentOperations } from "./root";
|
|
|
|
export type TAttachmentOperationsRemoveModal = Exclude<TAttachmentOperations, "create">;
|
|
|
|
type Props = {
|
|
isOpen: boolean;
|
|
onClose: () => void;
|
|
data: TIssueAttachment;
|
|
handleAttachmentOperations: TAttachmentOperationsRemoveModal;
|
|
};
|
|
|
|
export const IssueAttachmentDeleteModal: FC<Props> = (props) => {
|
|
const { isOpen, onClose, data, handleAttachmentOperations } = props;
|
|
// states
|
|
const [loader, setLoader] = useState(false);
|
|
|
|
const handleClose = () => {
|
|
onClose();
|
|
setLoader(false);
|
|
};
|
|
|
|
const handleDeletion = async (assetId: string) => {
|
|
setLoader(true);
|
|
handleAttachmentOperations.remove(assetId).finally(() => handleClose());
|
|
};
|
|
|
|
return (
|
|
<AlertModalCore
|
|
handleClose={handleClose}
|
|
handleSubmit={() => handleDeletion(data.id)}
|
|
isDeleting={loader}
|
|
isOpen={isOpen}
|
|
title="Delete attachment"
|
|
content={
|
|
<>
|
|
Are you sure you want to delete attachment-{" "}
|
|
<span className="font-bold">{getFileName(data.attributes.name)}</span>? This attachment will be permanently
|
|
removed. This action cannot be undone.
|
|
</>
|
|
}
|
|
/>
|
|
);
|
|
};
|