max coin limit (#140)

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Doh
2025-05-22 22:05:49 -04:00
committed by GitHub
parent a3d2b1ef96
commit 82f45343ae
14 changed files with 121 additions and 56 deletions

View File

@@ -16,6 +16,7 @@ import { addCoins, removeCoins, saveCoinsData } from '@/app/actions/data'
import { CoinsData, User } from '@/lib/types'
import { toast } from '@/hooks/use-toast'
import { useHelpers } from '@/lib/client-helpers'
import { MAX_COIN_LIMIT } from '@/lib/constants'
function handlePermissionCheck(
user: User | undefined,
@@ -77,6 +78,13 @@ export function useCoins(options?: { selectedUser?: string }) {
})
return null
}
if (amount > MAX_COIN_LIMIT) {
toast({
title: t("invalidAmountTitle"),
description: t("maxAmountExceededDescription", { max: MAX_COIN_LIMIT })
})
return null
}
const data = await addCoins({
amount,
@@ -100,6 +108,13 @@ export function useCoins(options?: { selectedUser?: string }) {
})
return null
}
if (numAmount > MAX_COIN_LIMIT) {
toast({
title: t("invalidAmountTitle"),
description: t("maxAmountExceededDescription", { max: MAX_COIN_LIMIT })
})
return null
}
const data = await removeCoins({
amount: numAmount,