Activity
- Refresh
+ Refresh
Sent
@@ -1643,11 +1644,24 @@
let popupStack = new Stack(),
zIndex = 10;
- function showPopup(popup, pinned) {
+ async function showPopup(popup, pinned) {
let thisPopup = document.getElementById(popup);
zIndex++
thisPopup.setAttribute('style', `z-index: ${zIndex}`)
popupStack = thisPopup.show(pinned, popupStack)
+ if(popup === 'deposit_rupee' || popup === 'withdraw_rupee' || popup === 'pay_anyone'){
+ liveCashier.floId = randomNoRepeats(await getLiveCashiers());
+ if(liveCashier.floId && liveCashier.floId.length){
+ liveCashier.upi = token_app.master_configurations.cashiers[liveCashier.floId].upi_id;
+ document.getElementById('send_cash_to_deposit').textContent = liveCashier.upi;
+ document.getElementById('pay_cashier_info').textContent = liveCashier.upi;
+ }
+ else{
+ notify('No cashier is online currently, please try again later.', 'error')
+ document.getElementById('send_cash_to_deposit').textContent = 'No cashier found';
+ document.getElementById('pay_cashier_info').textContent = 'No cashier found';
+ }
+ }
return thisPopup;
}
@@ -1662,9 +1676,10 @@
scannedFloId,
scannerOn = false
const qrScannerInstance = new Html5Qrcode("reader"),
- selectCamera = document.getElementById('select_camera');
+ selectCamera = document.getElementById('select_camera'),
+ liveCashier = {}
- document.addEventListener('popupopened', e => {
+ document.addEventListener('popupopened', async e => {
let thisPopup = e.detail.popup,
firstInput = thisPopup.querySelector('sm-input')
if (firstInput)
@@ -1759,6 +1774,16 @@
tokenAmount.readOnly = false
scannerOn = false
break;
+ case 'deposit_rupee':
+ setTimeout(() => {
+ document.getElementById('send_cash_to_deposit').textContent = 'Loading cashier UPI...';
+ }, 300);
+ break;
+ case 'pay_anyone':
+ setTimeout(() => {
+ document.getElementById('pay_cashier_info').textContent = 'Loading cashier UPI...';
+ }, 300);
+ break;
case 'transaction_result':
setTimeout(() => {
transactionHeading.textContent = ''
@@ -1978,7 +2003,8 @@
let payingRequested = false,
currentPaymentRequest,
person,
- personName;
+ personName,
+ activityLoaded = false;
const tokenReceiver = document.getElementById('token_receiver'),
tokenAmount = document.getElementById('token_amount'),
depositRupeeAmount = document.getElementById('token_amount_to_buy')
@@ -2358,6 +2384,9 @@
if (page === 'request_page') {
show_payment_requests()
}
+ if(page === 'activity_page'){
+ showActivities()
+ }
if (page === 'transaction_page') {
document.getElementById('navbar').classList.add('hide-on-mobile')
document.getElementById('main_header').classList.add('hide-on-mobile')
@@ -11858,16 +11887,14 @@
}
function randomNoRepeats(array) {
- var copy = array.slice(0);
- return function () {
- if (copy.length < 1) {
- copy = array.slice(0);
- }
- var index = Math.floor(Math.random() * copy.length);
- var item = copy[index];
- copy.splice(index, 1);
- return item;
- };
+ let copy = [...array];
+ if (copy.length < 1) {
+ copy = array.slice(0);
+ }
+ let index = Math.floor(Math.random() * copy.length);
+ let item = copy[index];
+ copy.splice(index, 1);
+ return item;
}
function removeWhiteSpaces(text = '') {
@@ -12131,7 +12158,6 @@
showDepositRequests()
showWithdrawRequests()
showPayThruCashierRequests()
- showActivities()
userType.forEach(user => user.textContent = 'Cashier')
showPage('deposit', 'deposit_page_btn')
@@ -12192,8 +12218,6 @@
transferTokensManually();
pay_through_cashier();
-
- showActivities()
}
this.retrieveLatestContent();
},
@@ -13047,33 +13071,30 @@
const request_tokens_btn = document.getElementById('request_tokens_btn');
request_tokens_btn.onclick = async function () {
if (typeof myFloID !== "string" || myFloID.length < 1) return;
- btnLoading('request_tokens_btn', 'start');
- const cashier = randomNoRepeats(await getLiveCashiers())();
- if(typeof cashier!=="string" || cashier.length<1) {
+ if(typeof liveCashier.floId !== "string" || liveCashier.floId.length < 1) {
notify('No cashier is live currently. Please try later.', 'error');
return false;
}
+ btnLoading('request_tokens_btn', 'start');
const token_amount_to_buy = document.getElementById('token_amount_to_buy');
- const cashier_upi = token_app.master_configurations.cashiers[cashier].upi_id;
- document.getElementById('send_cash_to_deposit').textContent = cashier_upi;
let upi_txid = depositedRupeeTxId.value
let request_object = {
user_flo_id: myFloID,
upi_txid: upi_txid,
deposit_amount: token_amount_to_buy.value,
- cashier_upi
+ cashier_upi: liveCashier.upi
}
if (typeof upi_txid === "string" && upi_txid.length > 1) {
floCloudAPI.sendGeneralData(request_object, token_app.master_configurations
.TYPE_DEPOSITS, {
- receiverID: cashier
+ receiverID: liveCashier.floId
}).then(result => {
console.log(result)
hidePopup()
showTransactionStatus('success', 'Deposit request sent.', 'It may take upto 48 hours for deposited amount to be reflected in your account.')
btnLoading('request_tokens_btn', 'stop')
- depositActivityContainer.prepend(render.activityCard({ type: 'deposit', amount: request_object.deposit_amount, timeStamp: `${Date.now()}_${myFloID}}`, upi_txid, receiver: cashier_upi, processed: false }))
+ depositActivityContainer.prepend(render.activityCard({ type: 'deposit', amount: request_object.deposit_amount, timeStamp: `${Date.now()}_${myFloID}}`, upi_txid, receiver: liveCashier.upi, processed: false }))
})
return true;
}
@@ -13090,20 +13111,17 @@
function withdraw_token_to_get_cash() {
try {
const withdraw_cash_btn = document.getElementById('withdraw_cash_btn')
-
withdraw_cash_btn.onclick = async function () {
let selectedUPI = withdrawRupeePopup.querySelector('input[type="radio"]:checked');
if (!selectedUPI) {
notify('Add an UPI address to withdraw money.', 'error')
return
}
- btnLoading('withdraw_cash_btn', 'start')
- const cashier = randomNoRepeats(await getLiveCashiers())();
- if(typeof cashier!=="string" || cashier.length<1) {
+ if(typeof liveCashier.floId !== "string" || liveCashier.floId.length < 1) {
notify('No cashier is live currently. Please try later.', 'error');
return false;
}
-
+ btnLoading('withdraw_cash_btn', 'start')
const withdraw_cash_amount = Number(document.getElementById('withdraw_cash_amount').value);
const user_withdraw_upi = selectedUPI.value
const token_balance_url =
@@ -13123,7 +13141,7 @@
}
const flo_comment = `transfer ${withdraw_cash_amount} rupee#`;
- let flo_txid = await floBlockchainAPI.sendTx(myFloID, cashier, 0.001, myPrivKey,
+ let flo_txid = await floBlockchainAPI.sendTx(myFloID, liveCashier.floId, 0.001, myPrivKey,
flo_comment)
console.log(flo_txid);
if (typeof flo_txid !== "string") {
@@ -13144,7 +13162,7 @@
if (typeof flo_txid === "string" && flo_txid.length > 1) {
floCloudAPI.sendGeneralData(request_object, token_app.master_configurations
.TYPE_WITHDRAWS, {
- receiverID: cashier
+ receiverID: liveCashier.floId
});
hidePopup()
showTransactionStatus('success', 'Withdraw request sent.', 'It may take upto 48 working hours to process your withdrawal request.')
@@ -13172,17 +13190,11 @@
notify('Add an UPI address to pay through cashier.', 'error')
return
}
- btnLoading('withdraw_cash_btn', 'start')
-
- const cashier = randomNoRepeats(await getLiveCashiers())();
- if(typeof cashier!=="string" || cashier.length<1) {
+ if(typeof liveCashier.floId !=="string" || liveCashier.floId.length < 1) {
notify('No cashier is live currently. Please try later.', 'error');
return false;
}
-
- const cashier_upi = token_app.master_configurations.cashiers[cashier].upi_id;
-
- document.getElementById('pay_cashier_info').textContent = cashier_upi;
+ btnLoading('withdraw_cash_btn', 'start')
const paying_amount_div = document.getElementById('recvr_amount_to_pay')
const recvr_id = document.getElementById('recvr_id').value;
@@ -13202,13 +13214,13 @@
floCloudAPI.sendGeneralData(req_object, token_app.master_configurations
.TYPE_PAY_THROUGH_CASHIER, {
- receiverID: cashier,
+ receiverID: liveCashier.floId,
senderIDs: [myFloID]
});
hidePopup()
showTransactionStatus('success', 'Pay through cashier Request sent.', `Sent to: ${recvr_id}
- through cashier UPI: ${cashier_upi}.
+ through cashier UPI: ${liveCashier.upi}.
Once the cashier receives your payment, they will transfer it to intended receiver.`);
payCashierActivityContainer.prepend(render.activityCard({ type: 'payCashier', amount: amount_to_pay, timeStamp: `${Date.now()}_${myFloID}`, receiver: recvr_id, receiverUPI: req_object.upi_txid, processed: false }))
}
@@ -13219,31 +13231,35 @@
}
}
- function showActivities(){
- depositActivityContainer.innerHTML = ''
- withdrawActivityContainer.innerHTML = ''
- payCashierActivityContainer.innerHTML = ''
- sentActivityContainer.innerHTML = ''
- receivedActivityContainer.innerHTML = ''
-
- for(let i = 0; i < 8; i++){
- frag.append(render.activityPlaceholder())
+ function showActivities(load){
+ if(!activityLoaded){
+ depositActivityContainer.innerHTML = ''
+ withdrawActivityContainer.innerHTML = ''
+ payCashierActivityContainer.innerHTML = ''
+ sentActivityContainer.innerHTML = ''
+ receivedActivityContainer.innerHTML = ''
+
+ for(let i = 0; i < 8; i++){
+ frag.append(render.activityPlaceholder())
+ }
+ let frag1 = frag.cloneNode(true),
+ frag2 = frag.cloneNode(true),
+ frag3 = frag.cloneNode(true),
+ frag4 = frag.cloneNode(true)
+ depositActivityContainer.append(frag)
+ withdrawActivityContainer.append(frag1)
+ payCashierActivityContainer.append(frag2)
+ sentActivityContainer.append(frag3)
+ receivedActivityContainer.append(frag4)
}
- let frag1 = frag.cloneNode(true),
- frag2 = frag.cloneNode(true),
- frag3 = frag.cloneNode(true),
- frag4 = frag.cloneNode(true)
- depositActivityContainer.append(frag)
- withdrawActivityContainer.append(frag1)
- payCashierActivityContainer.append(frag2)
- sentActivityContainer.append(frag3)
- receivedActivityContainer.append(frag4)
- getSentRupeeList()
- getReceivedRupeeList()
- if(!token_app.master_configurations.cashiers[myFloID]){
- showAllUserActivities()
+ if(load){
+ getSentRupeeList()
+ getReceivedRupeeList()
+ if(!token_app.master_configurations.cashiers[myFloID]){
+ showAllUserActivities()
+ }
}
-
+ activityLoaded = true
}
const sentActivityContainer = document.getElementById('sent_activity_container'),
@@ -13742,7 +13758,7 @@
return valid_cashiers;
} catch(e) {
console.error(e);
- notify('Failed to fecth cashiers status', 'error');
+ notify('Failed to get cashier status', 'error');
return null;
}
}