diff --git a/src/app/admin/embed/page.tsx b/src/app/admin/embed/page.tsx new file mode 100644 index 0000000..b9afa76 --- /dev/null +++ b/src/app/admin/embed/page.tsx @@ -0,0 +1,85 @@ + +'use client'; + +import { useEffect, useState } from 'react'; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, + CardFooter, +} from '@/components/ui/card'; +import { Label } from '@/components/ui/label'; +import { Textarea } from '@/components/ui/textarea'; +import { Button } from '@/components/ui/button'; +import { Clipboard } from 'lucide-react'; +import { useToast } from '@/hooks/use-toast'; + +export default function EmbedPage() { + const [embedCode, setEmbedCode] = useState(''); + const [origin, setOrigin] = useState(''); + const { toast } = useToast(); + + useEffect(() => { + // This ensures window is defined, as it's only available on the client + if (typeof window !== 'undefined') { + const currentOrigin = window.location.origin; + setOrigin(currentOrigin); + setEmbedCode( + `` + ); + } + }, []); + + const handleCopy = () => { + navigator.clipboard.writeText(embedCode).then( + () => { + toast({ + title: 'Copied to Clipboard', + description: 'The embed code has been copied successfully.', + }); + }, + (err) => { + toast({ + title: 'Failed to Copy', + description: 'Could not copy the code. Please try again.', + variant: 'destructive', + }); + console.error('Could not copy text: ', err); + } + ); + }; + + return ( + + + Embed EstimateFlow + + Copy and paste the code below into your website's HTML to embed the + cost estimator flow. + + + +
+
+ +