From da98a184f9593a3f383f7572d4b70516b2df9be5 Mon Sep 17 00:00:00 2001 From: "dayuan.jiang" Date: Wed, 26 Mar 2025 08:58:46 +0000 Subject: [PATCH] refactor: extract ResetWarningModal from chat-input.tsx --- components/chat-input.tsx | 39 +++--------------------- components/reset-warning-modal.tsx | 48 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 components/reset-warning-modal.tsx diff --git a/components/chat-input.tsx b/components/chat-input.tsx index c03b688..08bfcb1 100644 --- a/components/chat-input.tsx +++ b/components/chat-input.tsx @@ -3,6 +3,7 @@ import React, { useCallback, useRef, useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; +import { ResetWarningModal } from "@/components/reset-warning-modal"; import { Loader2, Send, @@ -17,14 +18,6 @@ import { TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog"; import Image from "next/image"; import { useDiagram } from "@/contexts/diagram-context"; @@ -233,35 +226,11 @@ export function ChatInput({ {/* Warning Modal */} - - - - Clear Everything? - - This will clear the current conversation and - reset the diagram. This action cannot be - undone. - - - - - - - - + onClear={handleClear} + /> void; + onClear: () => void; +} + +export function ResetWarningModal({ + open, + onOpenChange, + onClear, +}: ResetWarningModalProps) { + return ( + + + + Clear Everything? + + This will clear the current conversation and reset the + diagram. This action cannot be undone. + + + + + + + + + ); +}