plane/apps/web/core/components/labels/delete-label-modal.tsx
Aaron 553f01fde1
feat: migrate to pnpm from yarn (#7593)
* chore(repo): migrate to pnpm

* chore(repo): cleanup pnpm integration with turbo

* chore(repo): run lint

* chore(repo): cleanup tsconfigs

* chore: align TypeScript to 5.8.3 across monorepo; update pnpm override and catalog; pnpm install to update lockfile

* chore(repo): revert logger.ts changes

* fix: type errors

* fix: build errors

* fix: pnpm home setup in dockerfiles

---------

Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com>
2025-08-19 20:06:42 +05:30

88 lines
2.4 KiB
TypeScript

"use client";
import React, { useState } from "react";
import { observer } from "mobx-react";
import { useParams } from "next/navigation";
// types
import { PROJECT_SETTINGS_TRACKER_ELEMENTS, PROJECT_SETTINGS_TRACKER_EVENTS } from "@plane/constants";
import type { IIssueLabel } from "@plane/types";
// ui
import { AlertModalCore, TOAST_TYPE, setToast } from "@plane/ui";
// hooks
import { captureError, captureSuccess } from "@/helpers/event-tracker.helper";
import { useLabel } from "@/hooks/store/use-label";
type Props = {
isOpen: boolean;
onClose: () => void;
data: IIssueLabel | null;
};
export const DeleteLabelModal: React.FC<Props> = observer((props) => {
const { isOpen, onClose, data } = props;
// router
const { workspaceSlug, projectId } = useParams();
// store hooks
const { deleteLabel } = useLabel();
// states
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const handleClose = () => {
onClose();
setIsDeleteLoading(false);
};
const handleDeletion = async () => {
if (!workspaceSlug || !projectId || !data) return;
setIsDeleteLoading(true);
await deleteLabel(workspaceSlug.toString(), projectId.toString(), data.id)
.then(() => {
captureSuccess({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_deleted,
payload: {
name: data.name,
project_id: projectId,
},
});
handleClose();
})
.catch((err) => {
setIsDeleteLoading(false);
captureError({
eventName: PROJECT_SETTINGS_TRACKER_EVENTS.label_deleted,
payload: {
name: data.name,
project_id: projectId,
},
error: err,
});
const error = err?.error || "Label could not be deleted. Please try again.";
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: error,
});
});
};
return (
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDeletion}
isSubmitting={isDeleteLoading}
isOpen={isOpen}
title="Delete Label"
content={
<>
Are you sure you want to delete <span className="font-medium text-custom-text-100">{data?.name}</span>? This
will remove the label from all the work item and from any views where the label is being filtered upon.
</>
}
/>
);
});