import { useSelector } from "react-redux"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import WalletItemCard from "./WalletItemCard"; import WalletItemCardFamily from "./WalletItemCardFamily"; import { useEffect, useState } from "react"; import { PriceFormatter } from "../Helpers/PriceFormatter"; import SearchCom from "../Helpers/SearchCom"; import { localImgLoad } from "../../lib"; import background from "../../assets/images/bg-sky-blue.jpg"; import FamilyWalletRedeemOptions from "./FamilyWalletRedeemOptions"; /** * Renders a list of wallet items or a loading spinner depending on the state of the `wallet` object. */ export default function FamilyWalletBox({ wallet, payment }) { // const { loading, data } = wallet; // const { userDetails } = useSelector((state) => state.userDetails); // const accountType = userDetails?.account_type === "FAMILY"; const [selectedWallet, setSelectedWallet] = useState('') const [activeWalletBtn, setActiveWalletBtn] = useState('') const handleChangeWallet = ({target:{name}}) => { // FUNCTION TO SWITCH WALLET IF USER HAS MORE THAN TWO WALLETS const currentWalletSelected = wallet?.data?.filter((item) => item.code == name); setSelectedWallet(currentWalletSelected[0]) setActiveWalletBtn(name) // console.log(name, currentWalletSelected) } const image = selectedWallet?.code ? `${selectedWallet?.code.toLowerCase()}.svg` : "default.png"; useEffect(()=>{ setSelectedWallet(wallet.data[0]) setActiveWalletBtn(wallet?.data[0]?.code) },[wallet]) return (
Current Balance
{PriceFormatter(selectedWallet?.amount/100, selectedWallet?.code, undefined, "text-[2rem]")}
No Wallet Record Found