Transaction Requests
-
+ Deposits
Withdrawals
Pay Through Cashier
@@ -710,12 +710,17 @@
*If your request isn't completed in 12hrs, use REPORT to get
assistance from our helpline.
+ Sent
Deposits
Withdrawals
Pay through cashier
System Notifications
+
+
+ You haven't sent any rupee yet.
+
You haven't deposited rupee yet.
@@ -825,7 +830,6 @@
currentTimeout,
notificationSound = document.getElementById('notification_sound');
const render = {
- // returns an order element;
depositRequest(txid, floId) {
let card = document.createElement('div');
card.classList.add('request')
@@ -881,6 +885,63 @@
`;
return card;
},
+ activityCard(type, amount, timesStamp){
+ let card = document.createElement('div'),
+ composition = ``,
+ icon,
+ sign
+ card.classList.add('activity')
+ switch(type){
+ case 'sent':
+ icon = `
+
+ `
+ sign = '-'
+ break;
+ case 'deposit':
+ icon = `
+
+ `
+ sign = '+'
+ break;
+ case 'withdraw':
+ icon = `
+
+ `
+ sign = '-'
+ break;
+ }
+ composition = `
+ ${icon}
+ ${type}
+ ${sign} ₹${amount}
+ ${formatedTime(timesStamp)}
+ `
+ card.innerHTML = composition;
+ return card;
+ },
depositActivity(vectorClock, txid, amount) {
let card = document.createElement('div'),
time = parseInt(vectorClock.split('_')[0])
@@ -1341,11 +1402,14 @@
tokenAmount.disabled = false
break;
case 'transaction_result' :
+ setTimeout(() => {
transactionHeading.textContent = ''
transactionMessage.innerHTML = ''
transactionSuccessId.textContent = ''
+ transactionSuccessId.parentNode.classList.add('hide-completely')
transactionSuccessSection.classList.add('hide-completely')
transactionFailedSection.classList.add('hide-completely')
+ }, 300);
break;
case 'prompt':
if (thisPopup.querySelector('sm-input').value == '')
@@ -1457,6 +1521,7 @@
})
}
+ const currentYear = new Date().getFullYear()
function formatedTime(time) {
try {
let timeFrag = new Date(parseInt(time)).toString().split(' '),
@@ -1476,7 +1541,10 @@
finalHours = `${hours}:${minutes}`
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`
- return `${finalHours} ${month} ${date} ${year}`;
+ if(year == currentYear)
+ return `${finalHours} ${month} ${date}`;
+ else
+ return `${finalHours} ${month} ${date} ${year}`;
} catch (e) {
console.error(e);
return time;
@@ -1667,12 +1735,14 @@
transactionHeading.textContent = heading
transactionMessage.innerHTML = message
transactionSuccessId.textContent = transactionId
+ if(transactionId)
+ transactionSuccessId.parentNode.classList.remove('hide-completely')
+ else
+ transactionSuccessId.parentNode.classList.add('hide-completely')
if(status === 'success'){
transactionSuccessSection.classList.remove('hide-completely')
- transactionFailedSection.classList.add('hide-completely')
}
else{
- transactionSuccessSection.classList.add('hide-completely')
transactionFailedSection.classList.remove('hide-completely')
}
showPopup('transaction_result')
@@ -11354,8 +11424,6 @@
await this.retrieveLatestContent();
- request_rupee_token();
-
withdraw_token_to_get_cash();
transferTokensManually();
@@ -11760,11 +11828,11 @@
flo_comment)
console.log(flo_txid);
if (typeof flo_txid !== "string") {
- notify(`Transaction unsuccessful.`);
+ showTrasactionStatus('failure', `Transaction failed.`);
hidePopup()
return false;
} else {
- notify(`Transaction successful: ${flo_txid}`, 'success', true, true);
+ showTrasactionStatus('success', 'Rupee Sent', 'It may take upto 48 working hours for transaction to be completed.', flo_txid);
if (payingRequested === true) {
const all_reqs = floDapps.getNextGeneralData(token_app.master_configurations
.TYPE_REQUEST_PAYMENT, "0").reverse();
@@ -12082,7 +12150,6 @@
.TYPE_DEPOSITS, {
receiverID: cashier
}).then(result => {
- console.log(result);
hidePopup()
showTrasactionStatus('success', 'Deposit request sent.', 'It may take upto 48 hours for deposited amount to be reflected in your account.')
btnLoading('request_tokens_btn', 'stop')
@@ -12103,20 +12170,8 @@
const cashier = randomNoRepeats(Object.keys(token_app.master_configurations.cashiers))();
withdraw_cash_btn.onclick = async function () {
btnLoading('withdraw_cash_btn', 'start')
- if (typeof myFloID !== "string" || myFloID.length < 1) {
- notify(`Your Flo Id is invalid.`, 'error');
- return;
- }
const withdraw_cash_amount = Number(document.getElementById('withdraw_cash_amount').value);
const user_withdraw_upi = String(document.getElementById('user_withdraw_upi').value);
- if (withdraw_cash_amount < 1) {
- notify(`Invalid amount. Please provide a number above 0.`, 'error');
- return false;
- }
- if (!user_withdraw_upi.includes('@')) {
- notify(`Please enter a valid UPI id.`, 'error');
- return false;
- }
const token_balance_url =
`https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?token=rupee&floAddress=${myFloID}`;
const user_token_balance_object = await ajaxGet(token_balance_url);
@@ -12129,9 +12184,8 @@
}
const current_balance = Number(user_token_balance_object.balance);
if (current_balance < withdraw_cash_amount) {
- notify(`You have unsufficient balance to withdraw. You can withdraw only ₹${user_token_balance_object.balance}`,
- 'error', true, true);
hidePopup()
+ showTrasactionStatus('failure', 'Insufficient Balance', `You have only ₹${user_token_balance_object.balance} balance`)
return;
}
@@ -12140,8 +12194,8 @@
flo_comment)
console.log(flo_txid);
if (typeof flo_txid !== "string") {
- notify(`Transaction unsuccessful.`, 'error');
hidePopup()
+ showTrasactionStatus('failure', 'Withdrawal failed')
return false;
}
// TODO: Validate https://ranchimallflo.duckdns.org/api/v1.0/getTransactionDetails/${flo_txid}
@@ -12159,16 +12213,13 @@
.TYPE_WITHDRAWS, {
receiverID: cashier
});
- notify('Withdraw request sent successfully.');
hidePopup()
+ showTrasactionStatus('success', 'Withdraw request sent.', 'It may take upto 48 working hours to process your withdrawal request.')
return true;
}
- notify('Failed to send withdraw request to cashier.', 'error');
+ showTrasactionStatus('failure', 'Failed to send withdraw request.');
return true;
}
-
- const user_withdraw_upi = document.getElementById('user_withdraw_upi');
- //user_withdraw_upi.value = get_user_payment_details();
} catch (error) {
throw new Error(error)
@@ -12244,7 +12295,7 @@
upi_txid,
deposit_amount
} = usr_deposits.message;
- frag.append(render.depositActivity(usr_deposits.vectorClock, upi_txid, deposit_amount))
+ frag.append(render.activityCard('deposit', deposit_amount, usr_deposits.vectorClock, upi_txid))
}
depositActivityContainer.innerHTML = ``;
@@ -12256,8 +12307,7 @@
withdrawer_upi,
withdraw_amount
} = usr_withdraws.message;
- frag.append(render.withdrawActivity(usr_withdraws.vectorClock, token_txid, withdrawer_upi,
- withdraw_amount))
+ frag.append(render.activityCard('withdraw', withdraw_amount, usr_withdraws.vectorClock, token_txid, withdrawer_upi))
}
withdrawActivityContainer.innerHTML = ``;
withdrawActivityContainer.append(frag)
@@ -12507,13 +12557,12 @@
async function get_sent_rupee_list() {
try {
let senderIDs = [myFloID];
- let receiverID = myFloID;
floGlobals.appObjects[token_app.master_configurations.TYPE_SENT_TOKENS][flo_txid] = {
token_sender, token_receiver, token_amount, token_name_radio,
flo_txid, "datetime": + new Date()
};
await floCloudAPI.requestObjectData(token_app.master_configurations.TYPE_SENT_TOKENS,
- options = { receiverID, senderIDs });
+ options = { myFloID, senderIDs });
const sent_tokens_list = Object.keys(floGlobals.appObjects
[token_app.master_configurations.TYPE_SENT_TOKENS]);
@@ -12526,29 +12575,12 @@
}
}
- function get_user_payment_details() {
- try {
- const pay_key = `pay_key_${myFloID}`;
- var pay_id = localStorage.getItem(pay_key);
- if(typeof pay_id !=='string' || pay_id.length<1) throw new Error('Invalid payment id.');
- return pay_id;
- } catch(error) {
- notify('Please update your UPI or payment details in settings.', 'error', '', true);
- throw new Error(error)
- }
- }
-
async function update_my_payment_details(userUpi='') {
try {
compactIDB.writeData('userUpis', userUpi, userUpi)
console.log(await compactIDB.readAllData('userUpis'))
- // todo: validate upi_id
-
- /*const pay_key = `pay_key_${myFloID}`;
-
- localStorage.setItem(pay_key, payment_id);*/
notify('Your payment details updated successfully.')