/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import type { LucideIcon } from "lucide-react"; import { AlertTriangle, Info } from "lucide-react"; import React from "react"; // components import type { TButtonVariant } from "@plane/propel/button"; import { Button } from "@plane/propel/button"; import { cn } from "../utils"; import { EModalPosition, EModalWidth } from "./constants"; import { ModalCore } from "./modal-core"; // constants // helpers export type TModalVariant = "danger" | "primary"; type Props = { content: React.ReactNode | string; handleClose: () => void; handleSubmit: () => void; hideIcon?: boolean; isSubmitting: boolean; isOpen: boolean; position?: EModalPosition; primaryButtonText?: { loading: string; default: string; }; secondaryButtonText?: string; title: string; variant?: TModalVariant; width?: EModalWidth; customIcon?: React.ReactNode; }; const VARIANT_ICONS: Record = { danger: AlertTriangle, primary: Info, }; const BUTTON_VARIANTS: Record = { danger: "error-fill", primary: "primary", }; const VARIANT_CLASSES: Record = { danger: "bg-danger-subtle text-danger-primary", primary: "bg-accent-primary/20 text-accent-primary", }; export function AlertModalCore(props: Props) { const { content, handleClose, handleSubmit, hideIcon = false, isSubmitting, isOpen, position = EModalPosition.CENTER, primaryButtonText = { loading: "Deleting", default: "Delete", }, secondaryButtonText = "Cancel", title, variant = "danger", width = EModalWidth.XL, customIcon, } = props; const Icon = VARIANT_ICONS[variant]; return (
{!hideIcon && ( {customIcon ? <>{customIcon} : )}

{title}

{content}

); }