22 lines
893 B
JavaScript
22 lines
893 B
JavaScript
|
const token = docCookies.getItem("token");
|
||
|
const notificationElement = document.getElementById("notification");
|
||
|
const balanceElement = document.getElementById("balance");
|
||
|
|
||
|
window.addEventListener("load", async function () {
|
||
|
balanceElement.innerText = await getBalance(token);
|
||
|
});
|
||
|
|
||
|
document.getElementById("activate-form").addEventListener("submit", async (e) => {
|
||
|
e.preventDefault();
|
||
|
const id = document.getElementById("id").value;
|
||
|
const infoResult = await chequeInfo(id);
|
||
|
const activateResult = await activateCheque(token, id);
|
||
|
if (activateResult !== undefined) {
|
||
|
notificationElement.innerText = `+${infoResult['amount']} coins`;
|
||
|
notificationElement.style.color = "green";
|
||
|
balanceElement.innerText = activateResult;
|
||
|
} else {
|
||
|
notificationElement.innerText = "Incorrect ID!";
|
||
|
notificationElement.style.color = "red";
|
||
|
}
|
||
|
});
|