From 19043aa692c1d38cbd3caa0758515f9a7ba8049a Mon Sep 17 00:00:00 2001 From: i701 Date: Sat, 20 Sep 2025 14:25:48 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20set=20100=20MVR=20for=20default=20wallet?= =?UTF-8?q?=20topup=20amount=20=F0=9F=94=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/number-input.tsx | 107 +++++++++++----------- components/wallet.tsx | 173 ++++++++++++++++++------------------ lib/atoms.ts | 22 ++--- 3 files changed, 151 insertions(+), 151 deletions(-) diff --git a/components/number-input.tsx b/components/number-input.tsx index df84ac8..9d832bb 100644 --- a/components/number-input.tsx +++ b/components/number-input.tsx @@ -1,62 +1,63 @@ -import { cn } from "@/lib/utils"; import { Minus, Plus } from "lucide-react"; import { useEffect } from "react"; import { - Button, - Group, - Input, - Label, - NumberField, + Button, + Group, + Input, + Label, + NumberField, } from "react-aria-components"; +import { cn } from "@/lib/utils"; export default function NumberInput({ - maxAllowed, - label, - value, - onChange, - className, - isDisabled, + maxAllowed, + label, + value = 100, + onChange, + className, + isDisabled, }: { - maxAllowed?: number; - label: string; - value: number; - onChange: (value: number) => void; - className?: string; - isDisabled?: boolean; + maxAllowed?: number; + label: string; + value?: number; + onChange: (value: number) => void; + className?: string; + isDisabled?: boolean; }) { - useEffect(() => { - if (maxAllowed) { - if (value > maxAllowed) { - onChange(maxAllowed); - } - } - }, [maxAllowed, value, onChange]); - return ( - -
- - - - - - -
-
- ); + useEffect(() => { + if (maxAllowed) { + if (value > maxAllowed) { + onChange(maxAllowed); + } + } + }, [maxAllowed, value, onChange]); + + return ( + +
+ + + + + + +
+
+ ); } diff --git a/components/wallet.tsx b/components/wallet.tsx index 3c7753e..29d92bc 100644 --- a/components/wallet.tsx +++ b/components/wallet.tsx @@ -7,101 +7,100 @@ import { toast } from "sonner"; import { createTopup } from "@/actions/payment"; import { Button } from "@/components/ui/button"; import { - Drawer, - DrawerClose, - DrawerContent, - DrawerDescription, - DrawerFooter, - DrawerHeader, - DrawerTitle, - DrawerTrigger, + Drawer, + DrawerClose, + DrawerContent, + DrawerDescription, + DrawerFooter, + DrawerHeader, + DrawerTitle, + DrawerTrigger, } from "@/components/ui/drawer"; import { WalletDrawerOpenAtom, walletTopUpValue } from "@/lib/atoms"; import type { TopupType } from "@/lib/types"; import NumberInput from "./number-input"; export function Wallet({ walletBalance }: { walletBalance: number }) { - const pathname = usePathname(); - const [amount, setAmount] = useAtom(walletTopUpValue); - const [isOpen, setIsOpen] = useAtom(WalletDrawerOpenAtom); - const [disabled, setDisabled] = useState(false); - const router = useRouter(); + const pathname = usePathname(); + const [amount, setAmount] = useAtom(walletTopUpValue); + const [isOpen, setIsOpen] = useAtom(WalletDrawerOpenAtom); + const [disabled, setDisabled] = useState(false); + const router = useRouter(); - if (pathname === "/payment") { - return null; - } + if (pathname === "/payment") { + return null; + } - const data: TopupType = { - amount: Number.parseFloat(amount.toFixed(2)), - }; + const data: TopupType = { + amount: Number.parseFloat(amount.toFixed(2)), + }; - return ( - - - - - -
- - Wallet - -
- Your wallet balance is{" "} - - {new Intl.NumberFormat("en-US", { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - }).format(walletBalance)} - {" "} -
-
-
+ return ( + + + + + +
+ + Wallet + +
+ Your wallet balance is{" "} + + {new Intl.NumberFormat("en-US", { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }).format(walletBalance)} + {" "} +
+
+
-
- setAmount(value)} - maxAllowed={5000} - isDisabled={amount === 0} - /> -
- - - - - - -
-
-
- ); +
+ setAmount(value)} + maxAllowed={5000} + isDisabled={amount === 0} + /> +
+ + + + + + +
+
+
+ ); } diff --git a/lib/atoms.ts b/lib/atoms.ts index 07d1c82..8c33a69 100644 --- a/lib/atoms.ts +++ b/lib/atoms.ts @@ -10,7 +10,7 @@ export const discountPercentageAtom = atom(75); export const numberOfDevicesAtom = atom(1); export const numberOfDaysAtom = atom(30); export const numberOfMonths = atom(1); -export const walletTopUpValue = atom(1); +export const walletTopUpValue = atom(100); export const formulaResultAtom = atom(""); export const deviceCartAtom = atom([]); export const cartDrawerOpenAtom = atom(false); @@ -19,14 +19,14 @@ export const loadingDevicesToPayAtom = atom(false); // Export the atoms with their store export const atoms = { - initialPriceAtom, - discountPercentageAtom, - numberOfDevicesAtom, - numberOfDaysAtom, - numberOfMonths, - formulaResultAtom, - deviceCartAtom, - cartDrawerOpenAtom, - walletTopUpValue, - loadingDevicesToPayAtom, + initialPriceAtom, + discountPercentageAtom, + numberOfDevicesAtom, + numberOfDaysAtom, + numberOfMonths, + formulaResultAtom, + deviceCartAtom, + cartDrawerOpenAtom, + walletTopUpValue, + loadingDevicesToPayAtom, };