add success toast after copying code

This commit is contained in:
Abi Raja 2023-11-21 10:56:17 -05:00
parent e895dd4668
commit 2303ed6d05

View File

@ -13,7 +13,7 @@ import {
FaMobile,
FaUndo,
} from "react-icons/fa";
import copy from 'copy-to-clipboard';
import copy from "copy-to-clipboard";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs";
@ -26,6 +26,7 @@ import { OnboardingNote } from "./components/OnboardingNote";
import { usePersistedState } from "./hooks/usePersistedState";
import { UrlInputSection } from "./components/UrlInputSection";
import TermsOfServiceDialog from "./components/TermsOfServiceDialog";
import toast from "react-hot-toast";
function App() {
const [appState, setAppState] = useState<"INITIAL" | "CODING" | "CODE_READY">(
@ -113,8 +114,9 @@ function App() {
setUpdateInstruction("");
}
const handleCopyCode = useCallback(() => {
const doCopyCode = useCallback(() => {
copy(generatedCode);
toast.success("Copied to clipboard");
}, [generatedCode]);
return (
@ -256,7 +258,9 @@ function App() {
/>
<span
title="Copy Code"
className="flex items-center justify-center w-10 h-10 text-gray-500 hover:bg-gray-100 cursor-pointer rounded-lg text-sm p-2.5 absolute top-[20px] right-[20px]" onClick={handleCopyCode}>
className="flex items-center justify-center w-10 h-10 text-gray-500 hover:bg-gray-100 cursor-pointer rounded-lg text-sm p-2.5 absolute top-[20px] right-[20px]"
onClick={doCopyCode}
>
<FaCopy />
</span>
</div>