diff --git a/src/components/bcros/LoadingIcon.vue b/src/components/bcros/LoadingIcon.vue deleted file mode 100644 index 5bfa250e..00000000 --- a/src/components/bcros/LoadingIcon.vue +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/components/bcros/LoadingModal.vue b/src/components/bcros/LoadingModal.vue new file mode 100644 index 00000000..7667d51b --- /dev/null +++ b/src/components/bcros/LoadingModal.vue @@ -0,0 +1,26 @@ + + + + + + + + {{ spinnerText }} + + + + diff --git a/src/components/bcros/businessDetails/Links.vue b/src/components/bcros/businessDetails/Links.vue index fb1382d4..f7f85e4e 100644 --- a/src/components/bcros/businessDetails/Links.vue +++ b/src/components/bcros/businessDetails/Links.vue @@ -22,8 +22,8 @@ const { isAllowedToFile, isDisableNonBenCorps } = useBcrosBusiness() const isCommentOpen = ref(false) const isDissolutionDialogOpen = ref(false) const { goToCreatePage } = useBcrosNavigate() +const ui = useBcrosDashboardUi() const filings = useBcrosFilings() -const isFetchingDataSpinner = ref(false) const isAllowedBusinessSummary = computed(() => !!currentBusinessIdentifier.value && @@ -122,7 +122,7 @@ const promptChangeBusinessInfo = () => { /** Request and Download Business Summary Document. */ const downloadBusinessSummary = async (): Promise => { - isFetchingDataSpinner.value = true + ui.fetchingData = true const businessId = currentBusiness.value.identifier const apiURL = useRuntimeConfig().public.legalApiURL const summaryDocument: DocumentI = { @@ -130,12 +130,16 @@ const downloadBusinessSummary = async (): Promise => { 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 } - isFetchingDataSpinner.value = false + ui.fetchingData = false } /** Creates a draft filing and navigates to the Create UI to file a company dissolution filing. */ @@ -183,24 +187,6 @@ const contacts = getContactInfo('registries') - - - - - {{ $t('text.general.fetchingData') }} - - - isFilingStatus(filing.value, FilingStatu const isShowBody = ref(false) -const showDetails = () => { +const showDetails = async () => { if (filing.value.documents === undefined && filing.value.documentsLink) { - loadDocumentList(filing.value) + ui.fetchingData = true + + await loadDocumentList(filing.value).catch((error) => { + console.error('Failed to load the document list.', error) + // TO-DO: #25125 - show the download error dialog + }) + + // make the spinner display for another 250ms so it does not flash when the promise resolves quickly + await sleep(250) + + ui.fetchingData = false } isShowBody.value = !isShowBody.value } diff --git a/src/components/bcros/filing/common/HeaderActions.vue b/src/components/bcros/filing/common/HeaderActions.vue index 205ed25e..d3c53053 100644 --- a/src/components/bcros/filing/common/HeaderActions.vue +++ b/src/components/bcros/filing/common/HeaderActions.vue @@ -88,6 +88,8 @@ + + @@ -103,6 +105,7 @@ const { isAllowedToFile, isBaseCompany, isDisableNonBenCorps, isEntityCoop, isEn const { currentBusiness } = storeToRefs(useBcrosBusiness()) const { isBootstrapFiling } = useBcrosBusinessBootstrap() const { goToEditPage } = useBcrosNavigate() +const ui = useBcrosDashboardUi() const isCommentOpen = ref(false) const filings = useBcrosFilings() @@ -323,14 +326,24 @@ const actions: any[][] = [[ } ]] -const handleButtonClick = () => { +const handleButtonClick = async () => { // toggle expansion state isExpanded.value = !isExpanded.value // if the filing has documentsLink but the documents list is empty // (i.e., when View More is clicked for the first time), load the documents list if (filing.value.documents === undefined && filing.value.documentsLink) { - loadDocumentList(filing.value) + ui.fetchingData = true + + await loadDocumentList(filing.value).catch((error) => { + console.error('Failed to load the document list.', error) + // TO-DO: #25125 - show the download error dialog + }) + + // make the spinner display for another 250ms so it does not flash when the promise resolves quickly + await sleep(250) + + ui.fetchingData = false } } diff --git a/src/lang/en.json b/src/lang/en.json index f238a56a..a337674f 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -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" diff --git a/src/layouts/business.vue b/src/layouts/business.vue index 62ff8b0c..a34f2e63 100644 --- a/src/layouts/business.vue +++ b/src/layouts/business.vue @@ -1,8 +1,9 @@ - - - + + diff --git a/src/layouts/default.vue b/src/layouts/default.vue index 7ce70df2..6daeefa9 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -2,8 +2,6 @@ const route = useRoute() const { isStaffAccount } = useBcrosAccount() -const { dashboardIsLoading } = storeToRefs(useBcrosDashboardUi()) - const crumbConstructors = computed(() => { if (isStaffAccount) { return (route?.meta?.staffBreadcrumbs || []) as (() => BreadcrumbI)[] @@ -20,10 +18,7 @@ onMounted(async () => { - - - - + { } const dashboardIsLoading = computed(() => uiIsLoading.value.length > 0) + const fetchingData = ref(false) return { dashboardIsLoading, + fetchingData, trackUiLoadingStart, trackUiLoadingStop } diff --git a/src/utils/download-file.ts b/src/utils/download-file.ts index 093c7a8d..2e70358b 100644 --- a/src/utils/download-file.ts +++ b/src/utils/download-file.ts @@ -30,8 +30,6 @@ const camelCaseToWords = (s: string): string => { * @param filing the filing object */ export const loadDocumentList = async (filing: ApiResponseFilingI) => { - // TO-DO Add a loader state for loading documents #24451 - const t = useNuxtApp().$i18n.t const unknownStr = `[${t('text.general.unknown')}]` const { currentBusinessIdentifier } = storeToRefs(useBcrosBusiness()) diff --git a/src/utils/sleeps.ts b/src/utils/sleeps.ts new file mode 100644 index 00000000..eeea354e --- /dev/null +++ b/src/utils/sleeps.ts @@ -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 { + return new Promise(resolve => setTimeout(resolve, ms)) +}
+ {{ spinnerText }} +
- {{ $t('text.general.fetchingData') }} -