diff --git a/src/components/ToastTextToCad.tsx b/src/components/ToastTextToCad.tsx index 67706c606..0a8aca10c 100644 --- a/src/components/ToastTextToCad.tsx +++ b/src/components/ToastTextToCad.tsx @@ -2,7 +2,7 @@ import type { TextToCadIteration_type, TextToCad_type, } from '@kittycad/lib/dist/types/src/models' -import { useCallback, useEffect, useRef, useState } from 'react' +import { useCallback, useEffect, useRef } from 'react' import toast from 'react-hot-toast' import type { Mesh } from 'three' import { @@ -165,8 +165,6 @@ export function ToastTextToCadSuccess({ const wrapperRef = useRef(null) const canvasRef = useRef(null) const animationRequestRef = useRef() - const [hasCopied, setHasCopied] = useState(false) - const [showCopiedUi, setShowCopiedUi] = useState(false) const modelId = data.id const projectDirectoryPath = useProjectDirectoryPath() @@ -345,12 +343,10 @@ export function ToastTextToCadSuccess({ iconStart={{ icon: 'close', }} - data-negative-button={hasCopied ? 'close' : 'reject'} - name={hasCopied ? 'Close' : 'Reject'} + data-negative-button="reject" + name="Reject" onClick={() => { - if (!hasCopied) { - sendTelemetry(modelId, 'rejected', token).catch(reportRejection) - } + sendTelemetry(modelId, 'rejected', token).catch(reportRejection) if (isDesktop()) { // Delete the file from the project @@ -380,7 +376,7 @@ export function ToastTextToCadSuccess({ toast.dismiss(toastId) }} > - {hasCopied ? 'Close' : 'Reject'} + Reject {isDesktop() ? ( { // eslint-disable-next-line @typescript-eslint/no-floating-promises sendTelemetry(modelId, 'accepted', token) - // eslint-disable-next-line @typescript-eslint/no-floating-promises - navigator.clipboard.writeText(data.code || '// no code found') - setShowCopiedUi(true) - setHasCopied(true) + const code = data.code || '// no code found' - // Reset the button text after 5 seconds - setTimeout(() => { - setShowCopiedUi(false) - }, 5000) + systemIOActor.send({ + type: SystemIOMachineEvents.createKCLFile, + data: { + requestedProjectName: projectName, + requestedCode: code, + requestedFileName: fileName, + }, + }) + + toast.dismiss(toastId) }} > - {showCopiedUi ? 'Copied' : 'Copy to clipboard'} + Replace current file )}