feat(thank-you-page): convert to client component with confetti and UI enhancements
- Changed from server to client component to enable interactive features like confetti animation - Removed server-side translations and hardcoded Portuguese text for simplicity - Added confetti effect on page load and improved success icon with animations - Updated buttons and share functionality for better user experience - This enhances the donation thank you page with celebratory elements and client-side interactivity
This commit is contained in:
1 parent
ad62dd0de2
commit
8271d1fa31
7 files changed
+191
-54
No files matched your search
@@ -5,6 +5,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import confetti from "canvas-confetti";
|
||||
import {
|
||||
Heart,
|
||||
Coffee,
|
||||
@@ -68,6 +69,17 @@ export function DonationCard({
|
||||
|
||||
const Icon = icons[icon];
|
||||
|
||||
// Confetti ao abrir modal de agradecimento
|
||||
useEffect(() => {
|
||||
if (showThankYouModal) {
|
||||
confetti({
|
||||
particleCount: 100,
|
||||
spread: 70,
|
||||
origin: { y: 0.6 },
|
||||
});
|
||||
}
|
||||
}, [showThankYouModal]);
|
||||
|
||||
// Atualizar timer e verificar pagamento automaticamente
|
||||
useEffect(() => {
|
||||
if (!pixData?.expiresAt || !pixData?.pixId) {
|
||||
@@ -95,28 +107,37 @@ export function DonationCard({
|
||||
}
|
||||
};
|
||||
|
||||
// Verificar pagamento via localStorage
|
||||
const checkPaymentConfirmation = () => {
|
||||
const savedPixId = localStorage.getItem("currentPixId");
|
||||
const confirmedPixIds = localStorage.getItem("confirmedPixIds");
|
||||
// Verificar pagamento via API
|
||||
const checkPaymentConfirmation = async () => {
|
||||
if (!pixData?.pixId) return;
|
||||
|
||||
if (savedPixId && confirmedPixIds) {
|
||||
try {
|
||||
const confirmed = JSON.parse(confirmedPixIds);
|
||||
if (confirmed.includes(savedPixId)) {
|
||||
console.log("✅ Pagamento confirmado!");
|
||||
setPaymentConfirmed(true);
|
||||
setTimeout(() => {
|
||||
setShowPixModal(false);
|
||||
setShowThankYouModal(true);
|
||||
// Limpar
|
||||
localStorage.removeItem("currentPixId");
|
||||
}, 1000);
|
||||
clearInterval(timerInterval);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Erro ao verificar pagamento:", e);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/donations/status?pixId=${pixData.pixId}`
|
||||
);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.paid) {
|
||||
console.log("✅ Pagamento confirmado!");
|
||||
setPaymentConfirmed(true);
|
||||
|
||||
// Confetti celebration!
|
||||
confetti({
|
||||
particleCount: 100,
|
||||
spread: 70,
|
||||
origin: { y: 0.6 },
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
setShowPixModal(false);
|
||||
setShowThankYouModal(true);
|
||||
// Limpar localStorage
|
||||
localStorage.removeItem("currentPixId");
|
||||
}, 1000);
|
||||
clearInterval(timerInterval);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Erro ao verificar pagamento:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user