diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx index 82e6a8a443e..c67f0c2f21b 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx @@ -11,6 +11,7 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; +import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Separator } from "@/components/ui/separator"; @@ -39,6 +40,12 @@ export function CreditBalanceSection({ const [selectedAmount, setSelectedAmount] = useState( predefinedAmounts[0].value, ); + const [customAmount, setCustomAmount] = useState(""); + + const isSelectedAmountValid = + selectedAmount !== "" && + Number.isInteger(Number(selectedAmount)) && + Number(selectedAmount) > 0; return ( @@ -74,7 +81,10 @@ export function CreditBalanceSection({ { + setSelectedAmount(value); + setCustomAmount(""); + }} value={selectedAmount} > {predefinedAmounts.map((amount) => ( @@ -95,6 +105,30 @@ export function CreditBalanceSection({ ))} + + {/* Custom Amount Input */} +
+ + { + const val = e.target.value.replace(/^0+/, ""); + if (/^\d*$/.test(val)) { + setCustomAmount(val); + setSelectedAmount(val); + } + }} + /> +
{/* Top-up Summary and Button */} @@ -125,7 +159,7 @@ export function CreditBalanceSection({