'use client' import { WhatsAppIcon } from '@/components/socialIcons' import { Button } from '@/components/ui/button' import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle, } from '@/components/ui/dialog' import { XIcon } from 'lucide-react' import { useEffect, useState } from 'react' interface PetitionSuccessDialogProps { open: boolean onOpenChange: (open: boolean) => void petitionTitle: string signatureNumber: number | null } const numberFormatter = new Intl.NumberFormat('pt-BR') export const PetitionSuccessDialog = ({ open, onOpenChange, petitionTitle, signatureNumber, }: PetitionSuccessDialogProps) => { const [shareUrl, setShareUrl] = useState('') useEffect(() => { if (typeof window !== 'undefined') { setShareUrl(window.location.href) } }, []) const message = `Acabei de assinar o abaixo-assinado "${petitionTitle}". Some sua voz também: ${shareUrl}` const whatsappHref = `https://wa.me/?text=${encodeURIComponent(message)}` return (
Obrigado por assinar! {signatureNumber !== null ? (

Você é a assinatura nº{' '} {numberFormatter.format(signatureNumber)} .

) : null}
Sua assinatura foi registrada. Compartilhe o abaixo-assinado no WhatsApp para somar mais apoiadores.
) }