"use client"; import type { ReactNode } from "react"; import { useState } from "react"; import { Alert, Box, Button, Group, Paper, Stack, Text, TextInput } from "@mantine/core"; import { IconAlertTriangle, IconShieldExclamation } from "@tabler/icons-react"; const CONFIRMATION_PHRASE = "I understand"; interface DangerousActionConfirmationProps { title: string; warningTitle: string; warningBody: string; typePrompt: string; submitLabel: string; submitIcon: ReactNode; cancelLabel: string; onConfirm: () => void; onCancel: () => void; disabled?: boolean; color?: string; } export const DangerousActionConfirmation = ({ title, warningTitle, warningBody, typePrompt, submitLabel, submitIcon, cancelLabel, onConfirm, onCancel, disabled, color = "red", }: DangerousActionConfirmationProps) => { const [value, setValue] = useState(""); const isMatch = value.trim().toLowerCase() === CONFIRMATION_PHRASE.toLowerCase(); return ( {title} }> {warningTitle} {warningBody} {typePrompt} setValue(e.currentTarget.value)} placeholder={CONFIRMATION_PHRASE} disabled={disabled} styles={{ input: { fontFamily: "var(--mantine-font-family-monospace)", borderColor: isMatch ? "var(--mantine-color-green-6)" : undefined, }, }} /> ); };