import { forwardRef } from 'react'; import { CheckIcon } from 'lucide-react'; import { Spinner, DialogButton, InfoHoverCard, ESide } from '@librechat/client'; import type { TDangerButtonProps } from '~/common'; import type { ForwardedRef } from 'react'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; const DangerButton = (props: TDangerButtonProps, ref: ForwardedRef) => { const { id, onClick, mutation, disabled, confirmClear, infoTextCode, actionTextCode, className = '', showText = true, dataTestIdInitial, dataTestIdConfirm, infoDescriptionCode, confirmActionTextCode = 'com_ui_confirm_action', } = props; const localize = useLocalize(); const renderMutation = (node: React.ReactNode | string) => { if (mutation && mutation.isLoading) { return ; } return node; }; return (
{showText && (
{localize(infoTextCode)}
{infoDescriptionCode && }
)} {confirmClear ? (
{renderMutation(
) : (
{renderMutation(localize(actionTextCode))}
)}
); }; export default forwardRef(DangerButton);