import { DataTable } from '@/components/ui/DataTable'; import { getColumns } from './Column'; import { apiConfig } from '@/config/api.config'; import axios, { AxiosResponse } from 'axios'; import { Helmet } from 'react-helmet'; import { DialogContent, MenuItem, Radio, RadioGroup, FormControlLabel, FormControl, Dialog, DialogTitle, Typography, Button, Box, Breadcrumbs, Link } from '@mui/material'; import { useState, useEffect } from 'react'; import CloseIcon from '@mui/icons-material/Close'; import Divider from '@mui/material/Divider'; import ConfirmDialog from '@/components/confirm'; import { toast } from 'sonner'; import { Container, DataGridLoader, DataGridProvider, LoaderTransparant } from '@/components'; import { ListToolBar } from './ListToolbar'; import { RefreshCw } from 'lucide-react'; import { setgroups } from 'process'; const BASE_URL = apiConfig.service_customer; let initBalance = { id: '', msisdn: '', fullname: '', username: '', agent_name: '', balance_emoney: '', balance_merchant: '', balance_point: '', balance_deposit: '' }; const AgentBalance = () => { const [isDialogOpen, setIsDialogOpen] = useState(false); const [loading, setLoading] = useState(false); const [dataBalance, setDataBalance] = useState([]); const [formData, setFormData] = useState(initBalance); const [pageIndex, setPageIndex] = useState(1); const [pageSize, setPageSize] = useState(10); const [dialogType, setDialogType] = useState(''); const [dialogOpen, setDialogOpen] = useState(false); const [isReloading, setIsReloading] = useState(false); useEffect(() => { fetchAgentBalance(); }, []); async function fetchAgentBalance(): Promise { setIsReloading(true); try { let balances = await axios.get(`${BASE_URL}/customer/agent-balance`, { params: { limit: 20, page: 1, with_deleted: false, order_field: 'created_at', order_direction: 'DESC' } }); let temp = 1; let resBalance = balances.data.data.list.map((el: any) => { el.no = temp++; if (!el.agent_name) el.agent_name = '' return el; }); setDataBalance(resBalance); } catch (error: any) { alert(error.message); console.log(error); } finally { setIsReloading(false); } } const openDialog = () => setIsDialogOpen(true); const closeDialog = () => { setIsDialogOpen(false); setFormData(initBalance); }; function createGroup() { setDialogType('create'); openDialog(); } const handleUpdate = (group: any) => { setDialogType('update'); setIsDialogOpen(true); }; const handleReload = () => { setIsReloading(true); fetchAgentBalance(); }; if (loading) return ; return ( <> TPAY | Agent Balance {/* setDialogOpen(false)} title="Confirm Action" content={''} onYes={handleYes} onNo={() => setDialogOpen(false)} /> */}

Agent Balances

Dashboard Members Agent Balances
{isReloading && ( )} } layout={{ card: true }} serverSide={false} onRowSelectionChange={(selected, table: any) => { const selectedRow = table.getSelectedRowModel().rows[0]; if (selectedRow) handleUpdate(selectedRow.original); }} />
{/* */} {/*
{dialogType === 'create' ? 'Create New Group' : 'Update Group'}
} label="Yes" /> } label="No" />
*/}
); }; export default AgentBalance;