@@ -7,6 +7,7 @@ import LearnTGVaultsAbi from '@/abis/LearnTGVaults.json'
77import { Button } from '@/components/ui/button'
88import { getCsrfToken } from 'next-auth/react'
99import axios from 'axios'
10+ import { useToast } from '@/components/ui/use-toast'
1011
1112const erc20Abi = [
1213 {
@@ -68,6 +69,7 @@ export function DonateModal({
6869 const { address } = useAccount ( )
6970 const publicClient = usePublicClient ( )
7071 const { data : walletClient } = useWalletClient ( )
72+ const { toast } = useToast ( )
7173
7274 const [ usdtDecimals , setUsdtDecimals ] = useState < number > (
7375 + ( process . env . NEXT_PUBLIC_USDT_DECIMALS || 6 ) ,
@@ -290,7 +292,7 @@ export function DonateModal({
290292 const donationAmountUSD = parseFloat ( amount ) ;
291293 if ( donationAmountUSD > 0 ) {
292294 console . log ( `Notifying backend of ${ donationAmountUSD } USD donation.` )
293- await axios . post ( '/api/add-donation' , {
295+ const response = await axios . post ( '/api/add-donation' , {
294296 lang : lang ,
295297 walletAddress : address ,
296298 token : csrfToken ,
@@ -301,6 +303,15 @@ export function DonateModal({
301303 }
302304 } ) ;
303305 console . log ( `Successfully notified backend of ${ donationAmountUSD } USD donation.` ) ;
306+ if ( response . data . increment > 0 ) {
307+ toast ( {
308+ title : t ( 'Donation successful!' , '¡Donación exitosa!' ) ,
309+ description : t (
310+ `Your learning score has increased by ${ response . data . increment . toFixed ( 2 ) } !` ,
311+ `¡Tu puntaje de aprendizaje ha incrementado en ${ response . data . increment . toFixed ( 2 ) } !`
312+ ) ,
313+ } )
314+ }
304315 }
305316 }
306317 } catch ( apiError ) {
0 commit comments