token n legacy
This commit is contained in:
@ -50,6 +50,7 @@ const AgentBalance = () => {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [isReloading, setIsReloading] = useState(false);
|
||||
const [barcode, setBarcode] = useState('');
|
||||
const [token_legacy, setToken_legacy] = useState('');
|
||||
// const [selectedMember, setSelectedMember] = useState(initBalance);
|
||||
|
||||
useEffect(() => {
|
||||
@ -99,6 +100,9 @@ const AgentBalance = () => {
|
||||
setFormData(data);
|
||||
setDialogType('update');
|
||||
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 () => {
|
||||
@ -112,13 +116,10 @@ const AgentBalance = () => {
|
||||
try {
|
||||
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);
|
||||
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">
|
||||
<PaymentCard
|
||||
barcode={barcode}
|
||||
token_legacy={token_legacy}
|
||||
setToken_legacy={setToken_legacy}
|
||||
customerId={formData.id}
|
||||
agent_name={formData.agent_name}
|
||||
/>
|
||||
@ -199,8 +202,7 @@ const AgentBalance = () => {
|
||||
};
|
||||
|
||||
// ====================
|
||||
const PaymentCard = ({ barcode, agent_name, customerId }: any) => {
|
||||
const [token_legacy, setToken_legacy] = useState('');
|
||||
const PaymentCard = ({ barcode, agent_name, customerId, token_legacy, setToken_legacy }: any) => {
|
||||
const cardRef: any = useRef(null);
|
||||
|
||||
const waitForImageLoad = (img: HTMLImageElement): Promise<void> => {
|
||||
@ -247,7 +249,8 @@ const PaymentCard = ({ barcode, agent_name, customerId }: any) => {
|
||||
});
|
||||
toast.success(`Success Update Token Legacy`);
|
||||
} 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