diff --git a/src/pages/members/agent-balance/AgentBalance.tsx b/src/pages/members/agent-balance/AgentBalance.tsx index 4a1282b..a66fc30 100644 --- a/src/pages/members/agent-balance/AgentBalance.tsx +++ b/src/pages/members/agent-balance/AgentBalance.tsx @@ -15,7 +15,7 @@ import { DialogTitle, Typography, Button, - Box, + Box, Breadcrumbs, Link } from '@mui/material'; @@ -50,19 +50,15 @@ const AgentBalance = () => { const [dialogOpen, setDialogOpen] = useState(false); const [isReloading, setIsReloading] = useState(false); const [barcode, setBarcode] = useState(''); + const [requested_date, setRequested_date] = useState(''); const [token_legacy, setToken_legacy] = useState(''); // const [selectedMember, setSelectedMember] = useState(initBalance); useEffect(() => { - // fetchAgentBalance(); + // fetchAgentBalance(); }, []); - const fetchAgentBalance = async ( - page: number, - limit: number, - sorting: any, - filter: any - ) => { + const fetchAgentBalance = async (page: number, limit: number, sorting: any, filter: any) => { filter = filter.length ? filter : {}; let balances = await axios.get(`${BASE_URL}/customer/agent-balance`, { params: { @@ -78,11 +74,11 @@ const AgentBalance = () => { let temp = 1; let resBalance = balances.data.data.list.map((el: any) => { el.no = temp++; - if (!el.agent_name) el.agent_name = '' + if (!el.agent_name) el.agent_name = ''; return el; }); - return { data: resBalance, totalCount: balances?.data.data.total_count } - } + return { data: resBalance, totalCount: balances?.data.data.total_count }; + }; const openDialog = () => setIsDialogOpen(true); const closeDialog = () => { @@ -100,24 +96,35 @@ const AgentBalance = () => { setFormData(data); setDialogType('update'); setIsDialogOpen(true); - let getTokenLegacy = await axios.get(`${BASE_URL}/token/get-token-legacy`, { params: { id: data.id } }); + let getTokenLegacy = await axios.get(`${BASE_URL}/token/get-token-legacy`, { + params: { id: data.id } + }); let temp = getTokenLegacy?.data?.data?.token_legacy || ''; - setToken_legacy(temp) + setToken_legacy(temp); }; const handleReload = async () => { setIsReloading(true); - await fetchAgentBalance(currentPage, pageSize, '',''); - closeDialog() + await fetchAgentBalance(currentPage, pageSize, '', ''); + closeDialog(); setIsReloading(false); // fetchAgentBalance(); }; + function formatDate(value: string) { + const d = new Date(value); + const day = String(d.getDate()).padStart(2, '0'); + const month = String(d.getMonth() + 1).padStart(2, '0'); + const year = d.getFullYear(); + return `${day}-${month}-${year}`; + } + async function getQrCode(customerId: any): Promise { try { setBarcode(``); let getToken = await axios.get(`${BASE_URL}/token/get`, { params: { id: customerId } }); setBarcode(getToken.data.data.qrCode); + setRequested_date(formatDate(getToken.data.data.requested_date)); } catch (error: any) { toast.warning(error.message); console.log(error); @@ -156,10 +163,9 @@ const AgentBalance = () => {
- {isReloading && ( - - )} - {!isReloading && (} + {!isReloading && ( + { /> )}
- {/* */} @@ -194,6 +199,7 @@ const AgentBalance = () => { customerId={formData.id} agent_name={formData.agent_name} handleReload={handleReload} + date={requested_date} /> @@ -204,7 +210,15 @@ const AgentBalance = () => { }; // ==================== -const PaymentCard = ({ barcode, agent_name, customerId, token_legacy, setToken_legacy, handleReload }: any) => { +const PaymentCard = ({ + barcode, + agent_name, + customerId, + token_legacy, + setToken_legacy, + handleReload, + date +}: any) => { const cardRef: any = useRef(null); const waitForImageLoad = (img: HTMLImageElement): Promise => { @@ -216,7 +230,7 @@ const PaymentCard = ({ barcode, agent_name, customerId, token_legacy, setToken_l img.onload = () => resolve(); } }); - }; + }; const handleDownload = async () => { if (!cardRef.current) return; @@ -252,7 +266,7 @@ const PaymentCard = ({ barcode, agent_name, customerId, token_legacy, setToken_l toast.success(`Success Update Token Legacy`); await handleReload(); } catch (error: any) { - let err_msg = error?.response?.data?.error || error.message + let err_msg = error?.response?.data?.error || error.message; toast.error(err_msg); } }; @@ -283,7 +297,7 @@ const PaymentCard = ({ barcode, agent_name, customerId, token_legacy, setToken_l

Imprime husi : Telin Digital Solution

-

Imprime : 01–06–2025

+

Imprime : {date}