Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 9x 9x 9x 9x 9x 9x 9x 44x 9x 9x 9x 1x 1x 1x 1x 1x 9x 4x 4x 4x 16x 16x 16x 4x 4x | import { ROUTES_PATH } from '../constants/routes.js'
import { formatDate, formatStatus } from "../app/format.js"
import Logout from "./Logout.js"
export default class {
constructor({ document, onNavigate, store, localStorage }) {
this.document = document
this.onNavigate = onNavigate
this.store = store
const buttonNewBill = document.querySelector(`button[data-testid="btn-new-bill"]`)
if (buttonNewBill) buttonNewBill.addEventListener('click', this.handleClickNewBill)
const iconEye = document.querySelectorAll(`div[data-testid="icon-eye"]`)
Eif (iconEye) iconEye.forEach(icon => {
icon.addEventListener('click', () => this.handleClickIconEye(icon))
})
new Logout({ document, localStorage, onNavigate })
}
handleClickNewBill = () => {
this.onNavigate(ROUTES_PATH['NewBill'])
}
handleClickIconEye = (icon) => {
const billUrl = icon.getAttribute("data-bill-url")
const imgWidth = Math.floor($('#modaleFile').width() * 0.5)
$('#modaleFile').find(".modal-body").html(`<div style='text-align: center;' class="bill-proof-container"><img width=${imgWidth} src=${billUrl} alt="Bill" /></div>`)
$('#modaleFile').modal('show')
return billUrl;
}
getBills = () => {
Eif (this.store) {
return this.store
.bills()
.list()
.then(snapshot => {
const bills = snapshot
.map(doc => {
try {
console.log("Bills.js - ", doc)
return {
...doc,
date: formatDate(doc.date),
status: formatStatus(doc.status)
}
} catch(e) {
// if for some reason, corrupted data was introduced, we manage here failing formatDate function
// log the error and return unformatted date in that case
console.log(e,'for',doc)
return {
...doc,
date: doc.date,
status: formatStatus(doc.status)
}
}
})
console.log('length', bills.length)
return bills
})
}
}
}
|