diff --git a/src/pages/transaction/disbursement-saldo/TransactionDisbursement.tsx b/src/pages/transaction/disbursement-saldo/TransactionDisbursement.tsx index e608cd6..72c660d 100644 --- a/src/pages/transaction/disbursement-saldo/TransactionDisbursement.tsx +++ b/src/pages/transaction/disbursement-saldo/TransactionDisbursement.tsx @@ -4,10 +4,11 @@ import { Breadcrumbs, Link } from '@mui/material'; import { Helmet } from 'react-helmet'; import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; -import { useState } from 'react'; +import { useState ,useEffect } from 'react'; import { useCallApi } from '@/hooks'; import { apiConfig } from '@/config/api.config'; import { toast } from 'sonner'; +import { getAuth } from '@/auth'; const TransactionDisbursement = () => { const [form, setForm] = useState({ @@ -15,8 +16,28 @@ const TransactionDisbursement = () => { amount: '', pin: '' }); + const [wallets, setWallets] = useState([]); const { GetData, PostData } = useCallApi(); + const parsedUser = getAuth()?.user; const API_URL = apiConfig.transaction; + const API_URL_WALLET = apiConfig.service_wallet + + useEffect(() => { + const fetchWallets = async () => { + try { + const response = await GetData(`${API_URL_WALLET}/dashboard/balance/account/${parsedUser.customer.id}`, {}); + if (response?.status === true) { + setWallets(response.data || []); + } else { + toast.warning(response?.message || 'Failed to fetch wallet data'); + } + } catch (error) { + toast.warning('Failed to fetch wallet data'); + } + }; + + fetchWallets(); + }, []); const handleSubmit = async (e: any) => { e.preventDefault(); @@ -61,6 +82,20 @@ const TransactionDisbursement = () => { Disbursement Saldo + {/* Wallet Section */} +
{wallet.wallet}
++ {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(wallet.amount)} +
+{wallet.wallet}
++ {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(wallet.amount)} +
+