diff --git a/public/media/images/fixed-card.png b/public/media/images/fixed-card.png new file mode 100644 index 0000000..93f612a Binary files /dev/null and b/public/media/images/fixed-card.png differ diff --git a/src/pages/members/agent-balance/AgentBalance.tsx b/src/pages/members/agent-balance/AgentBalance.tsx index df4ac80..49c159c 100644 --- a/src/pages/members/agent-balance/AgentBalance.tsx +++ b/src/pages/members/agent-balance/AgentBalance.tsx @@ -52,7 +52,7 @@ const AgentBalance = () => { // const [selectedMember, setSelectedMember] = useState(initBalance); useEffect(() => { - fetchAgentBalance(); + fetchAgentBalance(); }, []); async function fetchAgentBalance(): Promise { @@ -70,7 +70,7 @@ 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; }); setDataBalance(resBalance); @@ -95,7 +95,7 @@ const AgentBalance = () => { const handleUpdate = async (data: any) => { await getQrCode(data.id); - setFormData(data) + setFormData(data); setDialogType('update'); setIsDialogOpen(true); }; @@ -105,14 +105,14 @@ const AgentBalance = () => { fetchAgentBalance(); }; - async function getQrCode(customerId:any): Promise { + async function getQrCode(customerId: any): Promise { try { - setBarcode(``) - let getToken = await axios.get(`${BASE_URL}/token/get`, { params: { id: customerId }}); + setBarcode(``); + let getToken = await axios.get(`${BASE_URL}/token/get`, { params: { id: customerId } }); console.log(getToken.data.data); setBarcode(getToken.data.data.qrCode); } catch (error: any) { - toast.warning(error.message) + toast.warning(error.message); console.log(error); } finally { // setBarcode(`https://miro.medium.com/v2/resize:fit:250/1*DcceOyLkzU--EzP4PYKd_g.png`) @@ -151,9 +151,7 @@ const AgentBalance = () => {
- {isReloading && ( - - )} + {isReloading && } {
- +
@@ -188,16 +190,16 @@ const AgentBalance = () => { }; // ==================== -const PaymentCard = ({ barcode, agent_name, customerId }:any) => { +const PaymentCard = ({ barcode, agent_name, customerId }: any) => { const [token_legacy, setToken_legacy] = useState(''); - const cardRef:any = useRef(null); + const cardRef: any = useRef(null); const waitForImageLoad = (img: HTMLImageElement): Promise => { return new Promise((resolve) => { if (img.complete && img.naturalHeight !== 0) { resolve(); } else { - toast.warning(`No QR Code`) + toast.warning(`No QR Code`); img.onload = () => resolve(); } }); @@ -210,14 +212,14 @@ const PaymentCard = ({ barcode, agent_name, customerId }:any) => { if (img) { await waitForImageLoad(img); } else { - return toast.warning(`No QR Code`) + return toast.warning(`No QR Code`); } const canvas = await html2canvas(cardRef.current, { useCORS: true, allowTaint: false, backgroundColor: 'white', - scale: 2, + scale: 2 }); const dataUrl = canvas.toDataURL('image/png'); @@ -229,32 +231,49 @@ const PaymentCard = ({ barcode, agent_name, customerId }:any) => { const updateTokenLegacy = async () => { try { - if (!token_legacy) toast.warning(`Token Legacy can not be empty`) - await axios.post(`${BASE_URL}/token/insert-token-legacy`, { customerid: customerId, token_legacy }); - toast.success(`Success Update Token Legacy`) - } catch (error:any) { - toast.error(error.message) + if (!token_legacy) toast.warning(`Token Legacy can not be empty`); + await axios.post(`${BASE_URL}/token/insert-token-legacy`, { + customerid: customerId, + token_legacy + }); + toast.success(`Success Update Token Legacy`); + } catch (error: any) { + toast.error(error.message); } - } + }; return (
- {/* Card content to render */} -
-
-

- {agent_name} -

+
+ Card Frame + +
+

{agent_name}

+ {barcode && ( - Barcode +
+ Barcode +
)} + +
+ +
+
+

Imprime husi : Telin Digital Solution

+

Imprime : 01–06–2025

+
+
- +
- {/* Download Button */}
- -