token n legacy
This commit is contained in:
@ -50,6 +50,7 @@ const AgentBalance = () => {
|
|||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
const [isReloading, setIsReloading] = useState(false);
|
const [isReloading, setIsReloading] = useState(false);
|
||||||
const [barcode, setBarcode] = useState('');
|
const [barcode, setBarcode] = useState('');
|
||||||
|
const [token_legacy, setToken_legacy] = useState('');
|
||||||
// const [selectedMember, setSelectedMember] = useState(initBalance);
|
// const [selectedMember, setSelectedMember] = useState(initBalance);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -99,6 +100,9 @@ const AgentBalance = () => {
|
|||||||
setFormData(data);
|
setFormData(data);
|
||||||
setDialogType('update');
|
setDialogType('update');
|
||||||
setIsDialogOpen(true);
|
setIsDialogOpen(true);
|
||||||
|
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)
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleReload = async () => {
|
const handleReload = async () => {
|
||||||
@ -112,13 +116,10 @@ const AgentBalance = () => {
|
|||||||
try {
|
try {
|
||||||
setBarcode(``);
|
setBarcode(``);
|
||||||
let getToken = await axios.get(`${BASE_URL}/token/get`, { params: { id: customerId } });
|
let getToken = await axios.get(`${BASE_URL}/token/get`, { params: { id: customerId } });
|
||||||
console.log(getToken.data.data);
|
|
||||||
setBarcode(getToken.data.data.qrCode);
|
setBarcode(getToken.data.data.qrCode);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast.warning(error.message);
|
toast.warning(error.message);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
|
||||||
// setBarcode(`https://miro.medium.com/v2/resize:fit:250/1*DcceOyLkzU--EzP4PYKd_g.png`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +188,8 @@ const AgentBalance = () => {
|
|||||||
<div className="relative">
|
<div className="relative">
|
||||||
<PaymentCard
|
<PaymentCard
|
||||||
barcode={barcode}
|
barcode={barcode}
|
||||||
|
token_legacy={token_legacy}
|
||||||
|
setToken_legacy={setToken_legacy}
|
||||||
customerId={formData.id}
|
customerId={formData.id}
|
||||||
agent_name={formData.agent_name}
|
agent_name={formData.agent_name}
|
||||||
/>
|
/>
|
||||||
@ -199,8 +202,7 @@ const AgentBalance = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ====================
|
// ====================
|
||||||
const PaymentCard = ({ barcode, agent_name, customerId }: any) => {
|
const PaymentCard = ({ barcode, agent_name, customerId, token_legacy, setToken_legacy }: any) => {
|
||||||
const [token_legacy, setToken_legacy] = useState('');
|
|
||||||
const cardRef: any = useRef(null);
|
const cardRef: any = useRef(null);
|
||||||
|
|
||||||
const waitForImageLoad = (img: HTMLImageElement): Promise<void> => {
|
const waitForImageLoad = (img: HTMLImageElement): Promise<void> => {
|
||||||
@ -247,7 +249,8 @@ const PaymentCard = ({ barcode, agent_name, customerId }: any) => {
|
|||||||
});
|
});
|
||||||
toast.success(`Success Update Token Legacy`);
|
toast.success(`Success Update Token Legacy`);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast.error(error.message);
|
let err_msg = error?.response?.data?.error || error.message
|
||||||
|
toast.error(err_msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user