diff --git a/static/components/direct-messages/direct-messages.html b/static/components/direct-messages/direct-messages.html
index 5f74b37..ab7eee1 100644
--- a/static/components/direct-messages/direct-messages.html
+++ b/static/components/direct-messages/direct-messages.html
@@ -6,7 +6,9 @@
- {{productOverview(props.row, item.product_id)}}
+
+ {{productName(props.row, item.product_id)}}
+
+ {{productPrice(props.row, item.product_id)}}
+
+
Order ID:
diff --git a/static/components/order-list/order-list.js b/static/components/order-list/order-list.js
index cc77029..fe64ec5 100644
--- a/static/components/order-list/order-list.js
+++ b/static/components/order-list/order-list.js
@@ -67,6 +67,12 @@ async function orderList(path) {
label: 'Total',
field: 'total'
},
+ {
+ name: 'fiat',
+ align: 'left',
+ label: 'Fiat',
+ field: 'fiat'
+ },
{
name: 'paid',
align: 'left',
@@ -108,13 +114,33 @@ async function orderList(path) {
'YYYY-MM-DD HH:mm'
)
},
- productOverview: function (order, productId) {
+ satBtc(val, showUnit = true) {
+ return satOrBtc(val, showUnit, true)
+ },
+ formatFiat(value, currency) {
+ return Math.trunc(value) + ' ' + currency
+ },
+ productName: function (order, productId) {
product = order.extra.products.find(p => p.id === productId)
if (product) {
- return `${product.name} (${product.price} ${order.extra.currency})`
+ return product.name
}
return ''
},
+ productPrice: function (order, productId) {
+ product = order.extra.products.find(p => p.id === productId)
+ if (product) {
+ return `${product.price} ${order.extra.currency}`
+ }
+ return ''
+ },
+ orderTotal: function (order) {
+ return order.items.reduce((t, item) => {
+ console.log('### t, o', t, item)
+ product = order.extra.products.find(p => p.id === item.product_id)
+ return t + item.quantity * product.price
+ }, 0)
+ },
getOrders: async function () {
try {
const ordersPath = this.stallId
diff --git a/static/js/utils.js b/static/js/utils.js
index 86c4d00..49a585a 100644
--- a/static/js/utils.js
+++ b/static/js/utils.js
@@ -48,6 +48,16 @@ function isJson(str) {
}
}
+function satOrBtc(val, showUnit = true, showSats = false) {
+ const value = showSats
+ ? LNbits.utils.formatSat(val)
+ : val == 0
+ ? 0.0
+ : (val / 100000000).toFixed(8)
+ if (!showUnit) return value
+ return showSats ? value + ' sat' : value + ' BTC'
+}
+
function timeFromNow(time) {
// Get timestamps
let unixTime = new Date(time).getTime()