diff --git a/src/frontend/src/modules/Transactions/Transactions.vue b/src/frontend/src/modules/Transactions/Transactions.vue index a5405a560..fac41ddf9 100644 --- a/src/frontend/src/modules/Transactions/Transactions.vue +++ b/src/frontend/src/modules/Transactions/Transactions.vue @@ -209,69 +209,29 @@ {{ $tc("phrases.exportTransactions") }} - - - - {{ $tc("words.status") }} - - - person - {{ $tc("words.service") }} - - - phone - {{ $tc("words.sender") }} - - - money - {{ $tc("words.amount") }} - - - {{ $tc("words.type") }} - - - {{ $tc("words.message") }} - - - calendar_today - {{ $tc("phrases.sentDate") }} - - - calendar_view_day - {{ $tc("phrases.processTime") }} - - - - - - + + + + check_circle_outline {{ $tc("words.confirm", 2) }} - + contact_support {{ $tc("words.process", 3) }} - + cancel {{ $tc("words.reject", 2) }} @@ -279,80 +239,102 @@ - + - - {{ transaction.sender }} + + + {{ item.sender }} - - {{ moneyFormat(transaction.amount) }} + + + {{ moneyFormat(item.amount) }} - - {{ transaction.type }} + + + {{ item.type }} - - {{ transaction.message }} + + + {{ item.message }} - -
- {{ timeForHuman(transaction.sentDate) }} + + +
+ {{ timeForHuman(item.sentDate) }} - ({{ timeForTimeZone(transaction.sentDate) }}) + ({{ timeForTimeZone(item.sentDate) }})
- -
+ + +
{{ $tc("phrases.inXSeconds", 1, { - x: timeDiffForHuman( - transaction.sentDate, - transaction.lastUpdate, - ), + x: timeDiffForHuman(item.sentDate, item.lastUpdate), }) }}
@@ -487,6 +469,8 @@ export default { showFilter: false, showBoxes: true, showExportModal: false, + currentSortBy: null, + currentSortOrder: "desc", analyticsPeriods: [ "Yesterday", "Same day last week", @@ -540,6 +524,45 @@ export default { closeFilter() { this.showFilter = false }, + onSort(sortData) { + this.currentSortBy = sortData && sortData.name ? sortData.name : null + this.currentSortOrder = sortData && sortData.type ? sortData.type : "desc" + this.loadTransactionsWithSort() + }, + async loadTransactionsWithSort(page = 1) { + try { + const params = { + page: page, + per_page: this.$route.query.per_page || 15, + } + + if (this.currentSortBy) { + const prefix = this.currentSortOrder === "desc" ? "-" : "" + params.sort_by = `${prefix}${this.currentSortBy}` + } + + const queryParams = this.$route.query + for (let k of Object.keys(queryParams)) { + if (k !== "page" && k !== "per_page") { + params[k] = queryParams[k] + } + } + + const response = await this.transactionService.paginator.loadPage( + page, + params, + ) + this.transactionService.updateList(response.data) + + EventBus.$emit( + "widgetContentLoaded", + this.subscriber, + this.transactionService.list.length, + ) + } catch (error) { + this.alertNotify("error", "Failed to load transactions") + } + }, filterTransaction(filterData) { let data = {} for (let i in filterData) { @@ -566,7 +589,11 @@ export default { }, reloadList(sub, data) { if (sub !== this.subscriber) return - this.transactionService.updateList(data) + if (this.currentSortBy) { + this.loadTransactionsWithSort() + } else { + this.transactionService.updateList(data) + } EventBus.$emit("dataLoaded") EventBus.$emit( "widgetContentLoaded",