Skip to content

Commit

Permalink
fix report crash when some values are null
Browse files Browse the repository at this point in the history
  • Loading branch information
Kukks committed Nov 10, 2023
1 parent 2326894 commit f2b1e5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion BTCPayServer/Views/UIReports/StoreReports.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<template v-else-if="srv.result.fields[columnIndex].type === 'tx_id'">
<vc:truncate-center text="value" is-vue="true" padding="15" classes="truncate-center-id" link="getExplorerUrl(value, row[columnIndex-1])" />
</template>
<template v-else-if="['Address', 'PaymentId'].includes(srv.result.fields[columnIndex].name)">
<template v-else-if="value && ['Address', 'PaymentId'].includes(srv.result.fields[columnIndex].name)" >
<vc:truncate-center text="value" is-vue="true" padding="15" classes="truncate-center-id" />
</template>
<template v-else-if="srv.result.fields[columnIndex].type === 'datetime'">{{ displayDate(value) }}</template>
Expand Down
7 changes: 5 additions & 2 deletions BTCPayServer/wwwroot/js/store-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ document.addEventListener("DOMContentLoaded", () => {
const dtFormatter = new Intl.DateTimeFormat('default', { dateStyle: 'short', timeStyle: 'short' });

function displayDate(val) {
if(!val){
return val;
}
const date = new Date(val);
return dtFormatter.format(date);
}
Expand Down Expand Up @@ -182,7 +185,7 @@ function downloadCSV() {

// Convert ISO8601 dates to YYYY-MM-DD HH:mm:ss so the CSV easily integrate with Excel
modifyFields(srv.result.fields, data, 'amount', displayValue)
modifyFields(srv.result.fields, data, 'datetime', v => moment(v).format('YYYY-MM-DD hh:mm:ss'));
modifyFields(srv.result.fields, data, 'datetime', v => v? moment(v).format('YYYY-MM-DD hh:mm:ss'): v);
const csv = Papa.unparse({ fields: srv.result.fields.map(f => f.name), data });
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
saveAs(blob, "export.csv");
Expand All @@ -202,7 +205,7 @@ async function fetchStoreReports() {
srv.dataUpdated();

// Dates from API are UTC, convert them to local time
modifyFields(srv.result.fields, srv.result.data, 'datetime', a => moment(a).format());
modifyFields(srv.result.fields, srv.result.data, 'datetime', a => a? moment(a).format(): a);
var urlParams = new URLSearchParams(new URL(window.location).search);
urlParams.set("viewName", srv.request.viewName);
urlParams.set("from", srv.request.timePeriod.from);
Expand Down

0 comments on commit f2b1e5f

Please sign in to comment.