Bug fixes

This commit is contained in:
sairaj mote 2023-04-01 03:16:42 +05:30
parent 564bd49768
commit 826cb771e4
3 changed files with 36 additions and 44 deletions

View File

@ -75,39 +75,6 @@
<script src="scripts/chainkyc.js"></script>
<script>
const { html, render: renderElem } = uhtml;
function getFormattedTime(timestamp, format) {
try {
if (String(timestamp).length < 13)
timestamp *= 1000
let [day, month, date, year] = new Date(timestamp).toString().split(' '),
minutes = new Date(timestamp).getMinutes(),
hours = new Date(timestamp).getHours(),
currentTime = new Date().toString().split(' ')
minutes = minutes < 10 ? `0${minutes}` : minutes
let finalHours = ``;
if (hours > 12)
finalHours = `${hours - 12}:${minutes}`
else if (hours === 0)
finalHours = `12:${minutes}`
else
finalHours = `${hours}:${minutes}`
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`
switch (format) {
case 'date-only':
return `${month} ${date}, ${year}`;
break;
case 'time-only':
return finalHours;
default:
return `${month} ${date}, ${year} at ${finalHours}`;
}
} catch (e) {
console.error(e);
return timestamp;
}
}
</script>
<script>
router.addRoute('', async state => {

View File

@ -321,7 +321,7 @@
if (getRef('aggregator_private_key').isValid) {
floBlockchainAPI.getBalance(address).then(balance => {
if (balance < 0.01) {
renderElem(getRef('aggregator_balance'), html`Balance: ${balance}FLO. You don't have enough FLO.`);
renderElem(getRef('aggregator_balance'), html`Balance: ${balance} FLO. You don't have enough FLO.`);
getRef('aggregator_balance').classList.add('error')
} else {
renderElem(getRef('aggregator_balance'), html`Balance: ${balance} FLO`);
@ -454,6 +454,7 @@
})
addressesToRevoke.clear()
render.approvedKycs()
clearSelection()
}).catch(e => {
notify(e, 'error')
}).finally(() => {

View File

@ -64,15 +64,38 @@ const getConfirmation = (title, options = {}) => {
})
})
}
// Use when a function needs to be executed after user finishes changes
const debounce = (callback, wait) => {
let timeoutId = null;
return (...args) => {
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => {
callback.apply(null, args);
}, wait);
};
function getFormattedTime(timestamp, format) {
try {
if (String(timestamp).length < 13)
timestamp *= 1000
let [day, month, date, year] = new Date(timestamp).toString().split(' '),
minutes = new Date(timestamp).getMinutes(),
hours = new Date(timestamp).getHours(),
currentTime = new Date().toString().split(' ')
minutes = minutes < 10 ? `0${minutes}` : minutes
let finalHours = ``;
if (hours > 12)
finalHours = `${hours - 12}:${minutes}`
else if (hours === 0)
finalHours = `12:${minutes}`
else
finalHours = `${hours}:${minutes}`
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`
switch (format) {
case 'date-only':
return `${month} ${date}, ${year}`;
break;
case 'time-only':
return finalHours;
default:
return `${month} ${date}, ${year} at ${finalHours}`;
}
} catch (e) {
console.error(e);
return timestamp;
}
}
class Router {
@ -158,7 +181,7 @@ function getApprovedAggregators() {
break;
case 'REVOKE_AGGREGATOR':
operationData.split(',').forEach(aggregator => {
floGlobals.approvedKycAggregators[floCrypto.toFloID(aggregator)].validTo = time * 1000;
delete floGlobals.approvedKycAggregators[floCrypto.toFloID(aggregator)]
});
break;
default:
@ -198,6 +221,7 @@ function getApprovedKycs() {
break;
case 'REVOKE_KYC':
operationData.split(',').forEach(address => {
if (!floGlobals.approvedKyc[address]) return
floGlobals.approvedKyc[address].validTo = time * 1000;
floGlobals.approvedKyc[address].revokedBy = vin[0].addr;
});