Skip to content

Commit 07642a1

Browse files
25471 - Loading state for download receipt (#3252)
1 parent bfa29df commit 07642a1

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

auth-web/src/components/auth/account-settings/transaction/Transactions.vue

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<template>
22
<v-container class="transaction-container">
3+
<v-fade-transition>
4+
<div
5+
v-if="isLoading"
6+
class="loading-container"
7+
>
8+
<v-progress-circular
9+
size="50"
10+
width="5"
11+
color="primary"
12+
:indeterminate="isLoading"
13+
/>
14+
</div>
15+
</v-fade-transition>
316
<header
417
v-if="title"
518
class="view-header align-center mb-5 ml-4"
@@ -69,6 +82,7 @@
6982
class="mt-4"
7083
:extended="extended"
7184
:headers="sortedHeaders"
85+
@isDownloadingReceipt="isLoading = $event"
7286
/>
7387
</section>
7488
<!-- export csv error -->
@@ -103,7 +117,7 @@
103117
<script lang="ts">
104118
import { Account, Pages } from '@/util/constants'
105119
import { MembershipType, OrgPaymentDetails } from '@/models/Organization'
106-
import { Ref, computed, defineComponent, onBeforeUnmount, onMounted, ref, watch } from '@vue/composition-api'
120+
import { Ref, computed, defineComponent, onBeforeUnmount, onMounted, ref, reactive, toRefs, watch } from '@vue/composition-api'
107121
import { useAccountChangeHandler, useTransactions } from '@/composables'
108122
import { BaseTableHeaderI } from '@/components/datatable/interfaces'
109123
import CommonUtils from '@/util/common-util'
@@ -137,6 +151,10 @@ export default defineComponent({
137151
const { setAccountChangedHandler, beforeDestroy } = useAccountChangeHandler()
138152
const { clearAllFilters, getTransactionReport, loadTransactionList, setViewAll, defaultSearchToOneYear } = useTransactions()
139153
154+
const state = reactive({
155+
isLoading: false
156+
})
157+
140158
// FUTURE: vue3 we can set this fn explicitly in the resource instead of doing it here
141159
const headers = getTransactionTableHeaders(props.extended)
142160
headers.forEach((header) => {
@@ -170,7 +188,6 @@ export default defineComponent({
170188
})
171189
172190
const credit = ref(0)
173-
const isLoading = ref(false)
174191
175192
const isTransactionsAllowed = computed((): boolean => {
176193
return [Account.PREMIUM, Account.STAFF, Account.SBC_STAFF]
@@ -204,7 +221,7 @@ export default defineComponent({
204221
}
205222
206223
const exportCSV = async () => {
207-
isLoading.value = true
224+
state.isLoading = true
208225
// grab from composable**
209226
const downloadData = await getTransactionReport()
210227
if (!downloadData || downloadData.error) {
@@ -215,7 +232,7 @@ export default defineComponent({
215232
} else {
216233
CommonUtils.fileDownload(downloadData, `bcregistry-transactions-${moment().format('MM-DD-YYYY')}.csv`, 'text/csv')
217234
}
218-
isLoading.value = false
235+
state.isLoading = false
219236
}
220237
221238
onMounted(() => {
@@ -224,14 +241,14 @@ export default defineComponent({
224241
onBeforeUnmount(() => { beforeDestroy() })
225242
226243
return {
244+
...toRefs(state),
227245
csvErrorDialog,
228246
csvErrorDialogText,
229247
headers,
230248
headerSelections,
231249
headersSelected,
232250
sortedHeaders,
233251
credit,
234-
isLoading,
235252
exportCSV
236253
}
237254
}
@@ -323,4 +340,8 @@ export default defineComponent({
323340
.credit-details {
324341
color: $gray7;
325342
}
343+
344+
.loading-container {
345+
background: rgba(255,255,255, 0.8);
346+
}
326347
</style>

auth-web/src/components/auth/account-settings/transaction/TransactionsDataTable.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ export default defineComponent({
182182
extended: { default: false },
183183
headers: { default: [] as BaseTableHeaderI[] }
184184
},
185-
setup (props) {
185+
emit: ['isDownloadingReceipt'],
186+
setup (props, { emit }) {
186187
// refs
187188
const datePicker = ref(null)
188189
// composables
@@ -273,10 +274,12 @@ export default defineComponent({
273274
})
274275
275276
async function downloadReceipt (item: Transaction) {
277+
emit('isDownloadingReceipt', true)
276278
const currentAccount = JSON.parse(ConfigHelper.getFromSession(SessionStorageKeys.CurrentAccount || '{}'))
277279
const receipt = await PaymentService.postReceipt(item, currentAccount.id)
278280
const filename = `bcregistry-receipts-${item.id}.pdf`
279281
CommonUtils.fileDownload(receipt.data, filename, 'application/pdf')
282+
emit('isDownloadingReceipt', false)
280283
}
281284
282285
const displayDate = (val: string) => {

0 commit comments

Comments
 (0)