Skip to content

Commit

Permalink
PR updates
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickpeinanw committed Jan 3, 2025
1 parent ba6720f commit df9e5fd
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
12 changes: 8 additions & 4 deletions src/components/bcros/businessDetails/Links.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ const downloadBusinessSummary = async (): Promise<void> => {
filename: `${businessId} Summary - ${todayIsoDateString()}.pdf`,
link: `${apiURL}/businesses/${businessId}/documents/summary`
}
const blob = await fetchDocuments(summaryDocument.link) // todo: show alert box on error
if (blob) {
saveBlob(blob, summaryDocument.filename)
try {
const blob = await fetchDocuments(summaryDocument.link)
if (blob) {
saveBlob(blob, summaryDocument.filename)
}
} catch (error) {
console.error('Failed to download business summary.', error)
// TO-DO: #25125 - show the download error dialog
}
ui.fetchingData = false
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/bcros/filing/CommonTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ const showDetails = async () => {
if (filing.value.documents === undefined && filing.value.documentsLink) {
ui.fetchingData = true
await loadDocumentList(filing.value)
await loadDocumentList(filing.value).catch((error) => {
console.error('Failed to load the document list.', error)
// TO-DO: #25125 - show the download error dialog
})
// wait for another 500ms to show the loading modal
await new Promise(resolve => setTimeout(resolve, 250))
// make the spinner display for another 250ms so it does not flash when the promise resolves quickly
await sleep(250)
ui.fetchingData = false
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/bcros/filing/common/HeaderActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,13 @@ const handleButtonClick = async () => {
if (filing.value.documents === undefined && filing.value.documentsLink) {
ui.fetchingData = true
await loadDocumentList(filing.value)
await loadDocumentList(filing.value).catch((error) => {
console.error('Failed to load the document list.', error)
// TO-DO: #25125 - show the download error dialog
})
// wait for another 500ms to show the loading modal
await new Promise(resolve => setTimeout(resolve, 500))
// make the spinner display for another 250ms so it does not flash when the promise resolves quickly
await sleep(250)
ui.fetchingData = false
}
Expand Down
3 changes: 2 additions & 1 deletion src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@
"act": "Act",
"the": "The",
"company": "Company",
"fetchingData": "Loading...",
"fetchingData": "Fetching Data",
"loadingDashboard": "Loading Dashboard",
"notifications": "Notifications",
"pendingNotifications": "No notifications | You have {n} pending approval | You have {n} pending approvals",
"notificationSubLabel": "{n} team member require approval to access this account | {n} team members require approval to access this account"
Expand Down
7 changes: 4 additions & 3 deletions src/layouts/business.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
const route = useRoute()
const t = useNuxtApp().$i18n.t
const { isStaffAccount } = useBcrosAccount()
const { dashboardIsLoading, fetchingData } = storeToRefs(useBcrosDashboardUi())
Expand All @@ -20,13 +21,13 @@ onMounted(async () => {
</script>

<template>
<BcrosLoadingModal :open="dashboardIsLoading" spinner-text="Loading Dashboard" />
<BcrosLoadingModal :open="fetchingData" spinner-text="Fetching Data" />
<BcrosLoadingModal :open="dashboardIsLoading" :spinner-text="t('text.general.loadingDashboard')" />
<BcrosLoadingModal :open="fetchingData" :spinner-text="t('text.general.fetchingData')" />
<div v-show="!dashboardIsLoading" class="app-container" data-cy="default-layout">
<bcros-header />
<div class="justify-center">
<bcros-system-banner
class="justify-center "
class="justify-center"
:message="systemMessage"
/>
</div>
Expand Down
6 changes: 1 addition & 5 deletions src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
const route = useRoute()
const { isStaffAccount } = useBcrosAccount()
const { dashboardIsLoading, fetchingData } = storeToRefs(useBcrosDashboardUi())
const crumbConstructors = computed(() => {
if (isStaffAccount) {
return (route?.meta?.staffBreadcrumbs || []) as (() => BreadcrumbI)[]
Expand All @@ -20,9 +18,7 @@ onMounted(async () => {
</script>

<template>
<BcrosLoadingModal :open="dashboardIsLoading" spinner-text="Loading Dashboard" />
<BcrosLoadingModal :open="fetchingData" spinner-text="Fetching Data" />
<div v-show="!dashboardIsLoading" class="app-container" data-cy="default-layout">
<div class="app-container" data-cy="default-layout">
<bcros-header />
<bcros-system-banner
class="justify-center"
Expand Down
8 changes: 8 additions & 0 deletions src/utils/sleeps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* "Sleeps" for specified timeout. Must be awaited.
* @param ms Delay to sleep, in milliseconds.
* @returns A promise to await upon.
*/
export function sleep (ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms))
}

0 comments on commit df9e5fd

Please sign in to comment.