import { useState, useEffect, Dispatch, useContext } from "react"; import { Tr, langCodeContext, LANG_OPTIONS, tr } from "@/translate"; import { ChatStore, ChatStoreMessage } from "@/types/chatstore"; import { EditMessageString } from "@/components/editMessageString"; import { EditMessageDetail } from "@/components/editMessageDetail"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Button } from "./ui/button"; import { AppChatStoreContext, AppContext } from "../pages/App"; import { ConfirmationDialog } from "./ui/confirmation-dialog"; interface EditMessageProps { chat: ChatStoreMessage; showEdit: boolean; setShowEdit: Dispatch; } export function EditMessage(props: EditMessageProps) { const { chatStore, setChatStore } = useContext(AppChatStoreContext); const [showConfirmDialog, setShowConfirmDialog] = useState(false); const { showEdit, setShowEdit, chat } = props; const handleSwitchMessageType = () => { if (typeof chat.content === "string") { chat.content = []; } else { chat.content = ""; } setChatStore({ ...chatStore }); }; return ( {/* */} Edit Message Make changes to the message content. {typeof chat.content === "string" ? ( ) : ( )} {chatStore.develop_mode && ( )} setShowConfirmDialog(false)} onConfirm={handleSwitchMessageType} title="Switch Message Type" description="Change message type will clear the content, are you sure?" /> ); }