Skip to content

Commit d8176cf

Browse files
committed
reporting increment in learningscore after donation
1 parent f1a1990 commit d8176cf

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

apps/nextjs/app/api

Submodule api updated from b823935 to a45895b

apps/nextjs/components/DonateModal.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import LearnTGVaultsAbi from '@/abis/LearnTGVaults.json'
77
import { Button } from '@/components/ui/button'
88
import { getCsrfToken } from 'next-auth/react'
99
import axios from 'axios'
10+
import { useToast } from '@/components/ui/use-toast'
1011

1112
const 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

Comments
 (0)