diff --git a/.gitignore b/.gitignore index 7bd1804d..1d9c141f 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ logs .vscode #Cypress screenshots -cypress/screenshots \ No newline at end of file +cypress/screenshots +cypress/downloads diff --git a/cypress/fixtures/allowable-actions/bc-historical.json b/cypress/fixtures/allowable-actions/bc-historical.json new file mode 100644 index 00000000..84795206 --- /dev/null +++ b/cypress/fixtures/allowable-actions/bc-historical.json @@ -0,0 +1,7 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [] + } + } +} diff --git a/cypress/fixtures/allowable-actions/ben-active.json b/cypress/fixtures/allowable-actions/ben-active.json new file mode 100644 index 00000000..0eb091f0 --- /dev/null +++ b/cypress/fixtures/allowable-actions/ben-active.json @@ -0,0 +1,64 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Request for AGM Extension", + "name": "agmExtension" + }, + { + "displayName": "AGM Location Change", + "name": "agmLocationChange" + }, + { + "displayName": "Alteration", + "name": "alteration" + }, + { + "displayName": "Amalgamation Application (Regular)", + "name": "amalgamationApplication", + "type": "regular" + }, + { + "displayName": "Amalgamation Application Short-form (Vertical)", + "name": "amalgamationApplication", + "type": "vertical" + }, + { + "displayName": "Amalgamation Application Short-form (Horizontal)", + "name": "amalgamationApplication", + "type": "horizontal" + }, + { + "displayName": "Annual Report", + "name": "annualReport" + }, + { + "displayName": "Address Change", + "name": "changeOfAddress" + }, + { + "displayName": "Director Change", + "name": "changeOfDirectors" + }, + { + "displayName": "6-Month Consent to Continue Out", + "name": "consentContinuationOut" + }, + { + "displayName": "Voluntary Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "BC Benefit Company Incorporation Application", + "name": "incorporationApplication" + }, + { + "displayName": "Transition Application", + "name": "transition" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/ben-historical.json b/cypress/fixtures/allowable-actions/ben-historical.json new file mode 100644 index 00000000..84795206 --- /dev/null +++ b/cypress/fixtures/allowable-actions/ben-historical.json @@ -0,0 +1,7 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [] + } + } +} diff --git a/cypress/fixtures/allowable-actions/cc-active.json b/cypress/fixtures/allowable-actions/cc-active.json new file mode 100644 index 00000000..2975df56 --- /dev/null +++ b/cypress/fixtures/allowable-actions/cc-active.json @@ -0,0 +1,64 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Request for AGM Extension", + "name": "agmExtension" + }, + { + "displayName": "AGM Location Change", + "name": "agmLocationChange" + }, + { + "displayName": "Alteration", + "name": "alteration" + }, + { + "displayName": "Amalgamation Application (Regular)", + "name": "amalgamationApplication", + "type": "regular" + }, + { + "displayName": "Amalgamation Application Short-form (Vertical)", + "name": "amalgamationApplication", + "type": "vertical" + }, + { + "displayName": "Amalgamation Application Short-form (Horizontal)", + "name": "amalgamationApplication", + "type": "horizontal" + }, + { + "displayName": "Annual Report", + "name": "annualReport" + }, + { + "displayName": "Address Change", + "name": "changeOfAddress" + }, + { + "displayName": "Director Change", + "name": "changeOfDirectors" + }, + { + "displayName": "6-Month Consent to Continue Out", + "name": "consentContinuationOut" + }, + { + "displayName": "Voluntary Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "BC Community Contribution Company Incorporation Application", + "name": "incorporationApplication" + }, + { + "displayName": "Transition Application", + "name": "transition" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/cp-active.json b/cypress/fixtures/allowable-actions/cp-active.json new file mode 100644 index 00000000..4d85e3f9 --- /dev/null +++ b/cypress/fixtures/allowable-actions/cp-active.json @@ -0,0 +1,33 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Annual Report", + "name": "annualReport" + }, + { + "displayName": "Address Change", + "name": "changeOfAddress" + }, + { + "displayName": "Director Change", + "name": "changeOfDirectors" + }, + { + "displayName": "Voluntary Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "Incorporation Application", + "name": "incorporationApplication" + }, + { + "displayName": "Special Resolution", + "name": "specialResolution" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/gp-active.json b/cypress/fixtures/allowable-actions/gp-active.json new file mode 100644 index 00000000..4af7805b --- /dev/null +++ b/cypress/fixtures/allowable-actions/gp-active.json @@ -0,0 +1,21 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Change of Registration Application", + "name": "changeOfRegistration" + }, + { + "displayName": "Statement of Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "BC General Partnership Registration", + "name": "registration" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/gp-historical.json b/cypress/fixtures/allowable-actions/gp-historical.json new file mode 100644 index 00000000..84795206 --- /dev/null +++ b/cypress/fixtures/allowable-actions/gp-historical.json @@ -0,0 +1,7 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [] + } + } +} diff --git a/cypress/fixtures/allowable-actions/sp-active.json b/cypress/fixtures/allowable-actions/sp-active.json new file mode 100644 index 00000000..0ae98c7c --- /dev/null +++ b/cypress/fixtures/allowable-actions/sp-active.json @@ -0,0 +1,21 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Change of Registration Application", + "name": "changeOfRegistration" + }, + { + "displayName": "Statement of Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "BC Sole Proprietorship Registration", + "name": "registration" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/staff/bc-active.json b/cypress/fixtures/allowable-actions/staff/bc-active.json new file mode 100644 index 00000000..a9e99814 --- /dev/null +++ b/cypress/fixtures/allowable-actions/staff/bc-active.json @@ -0,0 +1,107 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Admin Freeze", + "name": "adminFreeze" + }, + { + "displayName": "Request for AGM Extension", + "name": "agmExtension" + }, + { + "displayName": "AGM Location Change", + "name": "agmLocationChange" + }, + { + "displayName": "Alteration", + "name": "alteration" + }, + { + "displayName": "Amalgamation Application (Regular)", + "name": "amalgamationApplication", + "type": "regular" + }, + { + "displayName": "Amalgamation Application Short-form (Vertical)", + "name": "amalgamationApplication", + "type": "vertical" + }, + { + "displayName": "Amalgamation Application Short-form (Horizontal)", + "name": "amalgamationApplication", + "type": "horizontal" + }, + { + "displayName": "Annual Report", + "name": "annualReport" + }, + { + "displayName": "Address Change", + "name": "changeOfAddress" + }, + { + "displayName": "Director Change", + "name": "changeOfDirectors" + }, + { + "displayName": "6-Month Consent to Continue Out", + "name": "consentContinuationOut" + }, + { + "displayName": "Continuation Out", + "name": "continuationOut" + }, + { + "displayName": "Register Correction Application", + "name": "correction" + }, + { + "displayName": "Court Order", + "name": "courtOrder" + }, + { + "displayName": "Voluntary Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "Administrative Dissolution", + "name": "dissolution", + "type": "administrative" + }, + { + "displayName": "BC Limited Company Incorporation Application", + "name": "incorporationApplication" + }, + { + "displayName": "Registrar's Notation", + "name": "registrarsNotation" + }, + { + "displayName": "Registrar's Order", + "name": "registrarsOrder" + }, + { + "displayName": "Transition Application", + "name": "transition" + }, + { + "displayName": "Limited Restoration Extension Application", + "name": "restoration", + "type": "limitedRestorationExtension" + }, + { + "displayName": "Conversion to Full Restoration Application", + "name": "restoration", + "type": "limitedRestorationToFull" + }, + { + "displayName": "Notice of Withdrawal", + "name": "noticeOfWithdrawal" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/staff/bc-historical.json b/cypress/fixtures/allowable-actions/staff/bc-historical.json new file mode 100644 index 00000000..b38953b7 --- /dev/null +++ b/cypress/fixtures/allowable-actions/staff/bc-historical.json @@ -0,0 +1,34 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Court Order", + "name": "courtOrder" + }, + { + "displayName": "Correction - Put Back On", + "name": "putBackOn" + }, + { + "displayName": "Registrar's Notation", + "name": "registrarsNotation" + }, + { + "displayName": "Registrar's Order", + "name": "registrarsOrder" + }, + { + "displayName": "Full Restoration Application", + "name": "restoration", + "type": "fullRestoration" + }, + { + "displayName": "Limited Restoration Application", + "name": "restoration", + "type": "limitedRestoration" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/staff/ben-active.json b/cypress/fixtures/allowable-actions/staff/ben-active.json new file mode 100644 index 00000000..4b72a3ef --- /dev/null +++ b/cypress/fixtures/allowable-actions/staff/ben-active.json @@ -0,0 +1,107 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Admin Freeze", + "name": "adminFreeze" + }, + { + "displayName": "Request for AGM Extension", + "name": "agmExtension" + }, + { + "displayName": "AGM Location Change", + "name": "agmLocationChange" + }, + { + "displayName": "Alteration", + "name": "alteration" + }, + { + "displayName": "Amalgamation Application (Regular)", + "name": "amalgamationApplication", + "type": "regular" + }, + { + "displayName": "Amalgamation Application Short-form (Vertical)", + "name": "amalgamationApplication", + "type": "vertical" + }, + { + "displayName": "Amalgamation Application Short-form (Horizontal)", + "name": "amalgamationApplication", + "type": "horizontal" + }, + { + "displayName": "Annual Report", + "name": "annualReport" + }, + { + "displayName": "Address Change", + "name": "changeOfAddress" + }, + { + "displayName": "Director Change", + "name": "changeOfDirectors" + }, + { + "displayName": "6-Month Consent to Continue Out", + "name": "consentContinuationOut" + }, + { + "displayName": "Continuation Out", + "name": "continuationOut" + }, + { + "displayName": "Register Correction Application", + "name": "correction" + }, + { + "displayName": "Court Order", + "name": "courtOrder" + }, + { + "displayName": "Voluntary Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "Administrative Dissolution", + "name": "dissolution", + "type": "administrative" + }, + { + "displayName": "BC Benefit Company Incorporation Application", + "name": "incorporationApplication" + }, + { + "displayName": "Registrar's Notation", + "name": "registrarsNotation" + }, + { + "displayName": "Registrar's Order", + "name": "registrarsOrder" + }, + { + "displayName": "Transition Application", + "name": "transition" + }, + { + "displayName": "Limited Restoration Extension Application", + "name": "restoration", + "type": "limitedRestorationExtension" + }, + { + "displayName": "Conversion to Full Restoration Application", + "name": "restoration", + "type": "limitedRestorationToFull" + }, + { + "displayName": "Notice of Withdrawal", + "name": "noticeOfWithdrawal" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/staff/gp-historical.json b/cypress/fixtures/allowable-actions/staff/gp-historical.json new file mode 100644 index 00000000..7c8e6e4d --- /dev/null +++ b/cypress/fixtures/allowable-actions/staff/gp-historical.json @@ -0,0 +1,24 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Court Order", + "name": "courtOrder" + }, + { + "displayName": "Correction - Put Back On", + "name": "putBackOn" + }, + { + "displayName": "Registrar's Notation", + "name": "registrarsNotation" + }, + { + "displayName": "Registrar's Order", + "name": "registrarsOrder" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/staff/sp-active.json b/cypress/fixtures/allowable-actions/staff/sp-active.json new file mode 100644 index 00000000..fa99ecfb --- /dev/null +++ b/cypress/fixtures/allowable-actions/staff/sp-active.json @@ -0,0 +1,50 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Admin Freeze", + "name": "adminFreeze" + }, + { + "displayName": "Change of Registration Application", + "name": "changeOfRegistration" + }, + { + "displayName": "Record Conversion", + "name": "conversion" + }, + { + "displayName": "Register Correction Application", + "name": "correction" + }, + { + "displayName": "Court Order", + "name": "courtOrder" + }, + { + "displayName": "Statement of Dissolution", + "name": "dissolution", + "type": "voluntary" + }, + { + "displayName": "Statement of Dissolution", + "name": "dissolution", + "type": "administrative" + }, + { + "displayName": "Registrar's Notation", + "name": "registrarsNotation" + }, + { + "displayName": "Registrar's Order", + "name": "registrarsOrder" + }, + { + "displayName": "BC Sole Proprietorship Registration", + "name": "registration" + } + ] + } + } +} diff --git a/cypress/fixtures/allowable-actions/staff/sp-historical.json b/cypress/fixtures/allowable-actions/staff/sp-historical.json new file mode 100644 index 00000000..7c8e6e4d --- /dev/null +++ b/cypress/fixtures/allowable-actions/staff/sp-historical.json @@ -0,0 +1,24 @@ +{ + "couldFile": { + "filing": { + "filingTypes": [ + { + "displayName": "Court Order", + "name": "courtOrder" + }, + { + "displayName": "Correction - Put Back On", + "name": "putBackOn" + }, + { + "displayName": "Registrar's Notation", + "name": "registrarsNotation" + }, + { + "displayName": "Registrar's Order", + "name": "registrarsOrder" + } + ] + } + } +} diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index e1cf665f..6b5a1361 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -136,6 +136,21 @@ Cypress.Commands.add('interceptAuthorizations', (businessIdentifier: string) => ) }) +Cypress.Commands.add('interceptAllowableActions', (isStaff, legalType = 'BC', state = 'ACTIVE') => { + let fixtureName = `${legalType.toLowerCase()}-${state.toLowerCase()}` + if (isStaff) { + fixtureName = 'staff/' + fixtureName + } + + cy.fixture(`allowable-actions/${fixtureName}`).then((response) => { + cy.intercept( + 'GET', + `**/api/v2/businesses/allowable/**`, + response + ) + }) +}) + Cypress.Commands.add('visitBusinessDash', ( identifier = 'BC0871427', @@ -148,6 +163,7 @@ Cypress.Commands.add('visitBusinessDash', cy.wait(500) // https://github.com/cypress-io/cypress/issues/27648 sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true') cy.interceptAuthorizations(identifier).as('authorizations') + cy.interceptAllowableActions(false, legalType, isHistorical ? 'HISTORICAL' : 'ACTIVE') cy.intercept('GET', '**/api/v1/users/**/settings', { fixture: 'settings.json' }).as('getSettings') cy.intercept( 'REPORT', @@ -217,6 +233,7 @@ Cypress.Commands.add('visitBusinessDashFor', // load interceptors cy.interceptAuthorizations(business.identifier).as('authorizations') + cy.interceptAllowableActions(asStaff, business.legalType, business.state) cy.interceptBusinessInfoFor(business).as('getBusinessInfo') cy.interceptBusinessContact(business.identifier, 'BEN').as('getBusinessContact') cy.interceptAddresses(business.legalType).as('getAddresses') diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 8db4faf4..2ab5e504 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -26,6 +26,8 @@ declare global { interceptAuthorizations (businessIdentifier: string): Chainable, + interceptAllowableActions (isStaff: boolean, legalType?: string, state?: string): Chainable, + visitBusinessDash ( identifier?: string, legalType?: string, diff --git a/src/components/bcros/businessDetails/LinkActions.vue b/src/components/bcros/businessDetails/LinkActions.vue index 401815c3..dc70eeb7 100644 --- a/src/components/bcros/businessDetails/LinkActions.vue +++ b/src/components/bcros/businessDetails/LinkActions.vue @@ -3,11 +3,13 @@ import type { ComputedRef } from 'vue' import type { DropdownItem } from '#ui/types' import { FilingTypes } from '@bcrs-shared-components/enums' import { FilingSubTypeE } from '~/enums/filing-sub-type-e' +import { useBcrosDashboardActions } from '~/stores/dashboardActions' const { currentBusiness } = storeToRefs(useBcrosBusiness()) const { goToDigitalCredentialsPage, goToBusinessDashboard } = useBcrosNavigate() const { isAllowedToFile } = useBcrosBusiness() +const { isButtonForActionVisible } = useBcrosDashboardActions() const { getStoredFlag } = useBcrosLaunchdarkly() const t = useNuxtApp().$i18n.t @@ -35,9 +37,9 @@ const allActions: ComputedRef> = computed(() => { name: 'digitalCredentials' }, { // - showButton: currentBusiness.value.state !== BusinessStateE.HISTORICAL, + showButton: isButtonForActionVisible(FilingTypes.DISSOLUTION, FilingSubTypeE.DISSOLUTION_VOLUNTARY), disabled: - !getStoredFlag('supported-dissolution-entities')?.includes(currentBusiness.value.legalType) && + !getStoredFlag('supported-dissolution-entities')?.includes(currentBusiness.value.legalType) || !isAllowedToFile(FilingTypes.DISSOLUTION, FilingSubTypeE.DISSOLUTION_VOLUNTARY), label: t('button.tombstone.menuAction.dissolveBusiness'), click: () => { @@ -48,7 +50,9 @@ const allActions: ComputedRef> = computed(() => { name: 'dissolveBusiness' }, { // - showButton: currentBusiness.value.state !== BusinessStateE.HISTORICAL, + showButton: + getStoredFlag('supported-consent-amalgamation-out-entities')?.includes(currentBusiness.value.legalType) && + isButtonForActionVisible(FilingTypes.CONSENT_AMALGAMATION_OUT), disabled: !isAllowedToFile(FilingTypes.CONSENT_AMALGAMATION_OUT), label: t('button.tombstone.menuAction.consentToAmalgamateOut'), click: () => { @@ -58,7 +62,10 @@ const allActions: ComputedRef> = computed(() => { name: 'consentToAmalgamateOut' }, { // - showButton: currentBusiness.value.state !== BusinessStateE.HISTORICAL, + + showButton: + getStoredFlag('supported-consent-continuation-out-entities')?.includes(currentBusiness.value.legalType) && + isButtonForActionVisible(FilingTypes.CONSENT_CONTINUATION_OUT), disabled: !isAllowedToFile(FilingTypes.CONSENT_CONTINUATION_OUT), label: t('button.tombstone.menuAction.consentToContinueOut'), click: () => { @@ -68,7 +75,9 @@ const allActions: ComputedRef> = computed(() => { name: 'consentToContinueOut' }, { // - showButton: currentBusiness.value.state !== BusinessStateE.HISTORICAL, + showButton: + getStoredFlag('supported-agm-extension-entities')?.includes(currentBusiness.value.legalType) && + isButtonForActionVisible(FilingTypes.AGM_EXTENSION), disabled: !isAllowedToFile(FilingTypes.AGM_EXTENSION), label: t('button.tombstone.menuAction.requestAgmExtension'), click: () => { @@ -81,7 +90,9 @@ const allActions: ComputedRef> = computed(() => { name: 'requestAgmExtension' }, { // - showButton: currentBusiness.value.state !== BusinessStateE.HISTORICAL, + showButton: + getStoredFlag('supported-agm-location-chg-entities')?.includes(currentBusiness.value.legalType) && + isButtonForActionVisible(FilingTypes.AGM_LOCATION_CHANGE), disabled: !isAllowedToFile(FilingTypes.AGM_LOCATION_CHANGE), label: t('button.tombstone.menuAction.requestAgmLocationChange'), click: () => { @@ -94,8 +105,10 @@ const allActions: ComputedRef> = computed(() => { name: 'requestAgmLocationChange' }, { // - showButton: currentBusiness.value.state !== BusinessStateE.HISTORICAL, - disabled: !isAllowedToFile(FilingTypes.AGM_LOCATION_CHANGE), + showButton: + getStoredFlag('supported-amalgamation-entities')?.includes(currentBusiness.value.legalType) && + isButtonForActionVisible(FilingTypes.AMALGAMATION_APPLICATION), + disabled: !isAllowedToFile(FilingTypes.AMALGAMATION_APPLICATION), label: t('button.tombstone.menuAction.amalgamate'), click: () => { goToBusinessDashboard(`/${currentBusiness.value.identifier}/amalgamation-selection`) diff --git a/src/components/bcros/filing/addStaffFiling/Index.vue b/src/components/bcros/filing/addStaffFiling/Index.vue index edb3c363..d77a425d 100644 --- a/src/components/bcros/filing/addStaffFiling/Index.vue +++ b/src/components/bcros/filing/addStaffFiling/Index.vue @@ -10,9 +10,8 @@ interface MenuActionItem extends DropdownItem { const filings = useBcrosFilings() const business = useBcrosBusiness() -const { - currentBusiness, showAmalgamateOut, showConsentAmalgamationOut, showConsentContinueOut, showContinueOut, isHistorical -} = storeToRefs(business) +const { isActionVisible } = useBcrosDashboardActions() +const { currentBusiness } = storeToRefs(business) const { goToBusinessDashboard, goToEditPage, goToCreatePage } = useBcrosNavigate() const openFreezeUnfreezeModal = ref(false) @@ -54,28 +53,28 @@ const restoreCompany = async (restorationType: FilingSubTypeE = null) => { const allActions: ComputedRef> = computed(() => { return [ { // - showButton: true, + showButton: isActionVisible(AllowableActionE.REGISTRARS_NOTATION), disabled: !business.isAllowed(AllowableActionE.REGISTRARS_NOTATION), datacy: 'registrar-notation', label: t('label.filing.staffFilingOptions.registrarsNotation'), click: () => { openRegistrarNotationModal.value = true } }, { // - showButton: true, + showButton: isActionVisible(AllowableActionE.REGISTRARS_ORDER), disabled: !business.isAllowed(AllowableActionE.REGISTRARS_ORDER), datacy: 'registrar-order', label: t('label.filing.staffFilingOptions.registrarsOrder'), click: () => { openRegistrarOrderModal.value = true } }, { // - showButton: true, + showButton: isActionVisible(AllowableActionE.COURT_ORDER), disabled: !business.isAllowed(AllowableActionE.COURT_ORDER), datacy: 'court-order', label: t('label.filing.staffFilingOptions.courtOrder'), click: () => { openCourtOrderModal.value = true } }, { // - showButton: business.isEntityFirm(), + showButton: isActionVisible(AllowableActionE.RECORD_CONVERSION), disabled: !business.isAllowed(AllowableActionE.RECORD_CONVERSION), datacy: 'record-conversion', label: t('label.filing.staffFilingOptions.recordConversion'), @@ -84,29 +83,29 @@ const allActions: ComputedRef> = computed(() => { } }, { // - showButton: !isHistorical.value, + showButton: isActionVisible(AllowableActionE.ADMINISTRATIVE_DISSOLUTION), disabled: !business.isAllowed(AllowableActionE.ADMINISTRATIVE_DISSOLUTION), datacy: 'dissolution', label: t('label.filing.staffFilingOptions.dissolution'), click: () => { openDissolutionModal.value = true } }, { // - showButton: isHistorical.value, + showButton: isActionVisible(AllowableActionE.RESTORATION), disabled: !business.isAllowed(AllowableActionE.RESTORATION), datacy: 'restore', label: t('label.filing.staffFilingOptions.restoreCompany'), click: () => { restoreCompany() } }, { // - showButton: business.isAllowed(AllowableActionE.PUT_BACK_ON), - disabled: false, + showButton: isActionVisible(AllowableActionE.PUT_BACK_ON), + disabled: !business.isAllowed(AllowableActionE.PUT_BACK_ON), datacy: 'put-back-on', label: t('label.filing.staffFilingOptions.putBackOn'), click: () => { openPutBackOnModal.value = true } }, { // - showButton: business.isAllowed(AllowableActionE.FREEZE_UNFREEZE), - disabled: false, + showButton: isActionVisible(AllowableActionE.FREEZE_UNFREEZE), + disabled: !business.isAllowed(AllowableActionE.FREEZE_UNFREEZE), datacy: 'admin-freeze', label: !currentBusiness?.value?.adminFreeze ? t('label.filing.staffFilingOptions.adminFreeze') @@ -114,7 +113,7 @@ const allActions: ComputedRef> = computed(() => { click: () => { openFreezeUnfreezeModal.value = true } }, { // - showButton: !isHistorical.value && showConsentAmalgamationOut.value, + showButton: isActionVisible(AllowableActionE.CONSENT_AMALGAMATION_OUT), disabled: !business.isAllowed(AllowableActionE.CONSENT_AMALGAMATION_OUT), datacy: 'consent-to-amalgamate-out', label: t('label.filing.staffFilingOptions.consentToAmalgamateOut'), @@ -123,7 +122,7 @@ const allActions: ComputedRef> = computed(() => { } }, { // - showButton: !isHistorical.value && showAmalgamateOut.value, + showButton: isActionVisible(AllowableActionE.AMALGAMATION_OUT), disabled: !business.isAllowed(AllowableActionE.AMALGAMATION_OUT), datacy: 'amalgamate-out', label: t('label.filing.staffFilingOptions.amalgamateOut'), @@ -132,7 +131,7 @@ const allActions: ComputedRef> = computed(() => { } }, { // - showButton: !isHistorical.value && showConsentContinueOut.value, + showButton: isActionVisible(AllowableActionE.CONSENT_CONTINUATION_OUT), disabled: !business.isAllowed(AllowableActionE.CONSENT_CONTINUATION_OUT), datacy: 'consent-to-continue-out', label: t('label.filing.staffFilingOptions.consentToContinueOut'), @@ -141,7 +140,7 @@ const allActions: ComputedRef> = computed(() => { } }, { // - showButton: !isHistorical.value && showContinueOut.value, + showButton: isActionVisible(AllowableActionE.CONTINUATION_OUT), disabled: !business.isAllowed(AllowableActionE.CONTINUATION_OUT), datacy: 'continue-out', label: t('label.filing.staffFilingOptions.continueOut'), @@ -150,15 +149,15 @@ const allActions: ComputedRef> = computed(() => { } }, { // - showButton: business.isAllowed(AllowableActionE.LIMITED_RESTORATION_EXTENSION), - disabled: false, + showButton: isActionVisible(AllowableActionE.LIMITED_RESTORATION_EXTENSION), + disabled: !business.isAllowed(AllowableActionE.LIMITED_RESTORATION_EXTENSION), datacy: 'extend-limited-restore', label: t('label.filing.staffFilingOptions.extendLimitedRestoration'), click: () => { restoreCompany(FilingSubTypeE.LIMITED_RESTORATION_EXTENSION) } }, { // - showButton: business.isAllowed(AllowableActionE.LIMITED_RESTORATION_TO_FULL), - disabled: false, + showButton: isActionVisible(AllowableActionE.LIMITED_RESTORATION_TO_FULL), + disabled: !business.isAllowed(AllowableActionE.LIMITED_RESTORATION_TO_FULL), datacy: 'convert-full-restore', label: t('label.filing.staffFilingOptions.fullRestoration'), click: () => { restoreCompany(FilingSubTypeE.LIMITED_RESTORATION_TO_FULL) } diff --git a/src/stores/business.ts b/src/stores/business.ts index 5464d424..516be7ca 100644 --- a/src/stores/business.ts +++ b/src/stores/business.ts @@ -238,36 +238,6 @@ export const useBcrosBusiness = defineStore('bcros/business', () => { return isTypeRestorationLimited.value || isTypeRestorationLimitedExtension.value }) - // computed variables for staff filing options - const showConsentAmalgamationOut = computed(() => { - return ( - (isBaseCompany() || isEntityCoop()) && - !!launchdarklyStore.getFeatureFlag('supported-consent-amalgamation-out-entities')?.includes( - currentBusiness.value.legalType) - ) - }) - const showAmalgamateOut = computed(() => { - return ( - (isBaseCompany() || isEntityCoop()) && - !!launchdarklyStore.getFeatureFlag('supported-amalgamation-out-entities')?.includes( - currentBusiness.value.legalType) - ) - }) - const showConsentContinueOut = computed(() => { - return ( - isBaseCompany() && - !!launchdarklyStore.getFeatureFlag('supported-consent-continuation-out-entities')?.includes( - currentBusiness.value.legalType) - ) - }) - const showContinueOut = computed(() => { - return ( - isBaseCompany() && - !!launchdarklyStore.getFeatureFlag('supported-continuation-out-entities')?.includes( - currentBusiness.value.legalType) - ) - }) - const isAllowedToFile = (filingType: FilingTypes, filingSubType?: FilingSubTypeE) => { if (!filingType || !currentBusiness.value?.allowedActions?.filing) { return false @@ -560,10 +530,6 @@ export const useBcrosBusiness = defineStore('bcros/business', () => { isTypeRestorationLimited, isTypeRestorationFull, isFirm, - showAmalgamateOut, - showConsentAmalgamationOut, - showContinueOut, - showConsentContinueOut, isAllowedToFile, isAllowed, createCommentBusiness, diff --git a/src/stores/dashboardActions.ts b/src/stores/dashboardActions.ts new file mode 100644 index 00000000..734ae683 --- /dev/null +++ b/src/stores/dashboardActions.ts @@ -0,0 +1,243 @@ +import { CorpTypeCd, FilingTypes } from '@bcrs-shared-components/enums' +import { FilingSubTypeE } from '~/enums/filing-sub-type-e' + +/** Manages bcros account data */ +export const useBcrosDashboardActions = defineStore('bcros/dashboardActions', () => { + const visibleActions: Ref = ref([]) + const _legalApiURL = useRuntimeConfig().public.legalApiURL + const businessStore = useBcrosBusiness() + const currentTypeAndStatus = computed((): string => { + if (!businessStore.currentBusiness) { + return '' + } + return businessStore.currentBusiness.legalType.toUpperCase() + + '|' + + businessStore.currentBusiness.state.toUpperCase() + }) + + async function fetchVisibleActions (businessType: string, businessStatus: string) { + interface CouldFileI { + couldFile: { + filing: { + filingTypes: FilingTypeI[] + } + } + } + + return await useBcrosFetch(`${_legalApiURL}/businesses/allowable/${businessType}/${businessStatus}`, {}) + .then(({ data, error }) => { + if (error.value || !data.value) { + console.warn('Error fetching visible actions for', businessType, businessStatus) + return undefined + } + return data?.value?.couldFile?.filing?.filingTypes + }) + } + + // fetch new set of visible actions each time the requirement changes (either legal type or business state) + watch(currentTypeAndStatus, (value, oldValue) => { + if (value && value !== oldValue) { + fetchVisibleActions(value.split('|')[0], value.split('|')[1]).then((data) => { + if (data) { + visibleActions.value = data + } + }) + } + }, { immediate: true }) + + const isAllowedToFile = (filingType: FilingTypes, filingSubType?: FilingSubTypeE) => { + if (!filingType || !(visibleActions.value?.length > 0)) { + return false + } + + const requestedFiling = visibleActions.value + .find(ft => ft.name === filingType && (filingSubType === undefined || ft.type === filingSubType)) + return !!requestedFiling + } + + // NB: this is intentionally kept the same as the isAllowedActions for now to keep monitoring requirements more easily + // we can move the other function in the future here, in this store, and then easily replace call to isAllowToFile + // with generic function that checks scenario depending on the need and injects appropriate function + const isActionVisible = (action: AllowableActionE) => { + if (!businessStore.currentBusiness) { + return false + } + const currentBusiness = businessStore.currentBusiness + + const isEntityFirm = businessStore.isEntityFirm + const isLegalType = businessStore.isLegalType + const isBusiness = !!currentBusiness.value?.identifier + + const { isStaffAccount } = useBcrosAccount() + const { getFeatureFlag } = useBcrosLaunchdarkly() + const legalType = currentBusiness.legalType + + switch (action) { + case AllowableActionE.ADDRESS_CHANGE: { + if (isEntityFirm()) { + return isAllowedToFile(FilingTypes.CHANGE_OF_REGISTRATION) + } + return isAllowedToFile(FilingTypes.CHANGE_OF_ADDRESS) + } + + case AllowableActionE.ADMINISTRATIVE_DISSOLUTION: { + // NB: specific entities are targeted via LaunchDarkly + const ff = !!getFeatureFlag('supported-dissolution-entities')?.includes(legalType) + return (ff && isAllowedToFile(FilingTypes.DISSOLUTION, FilingSubTypeE.DISSOLUTION_ADMINISTRATIVE)) + } + + case AllowableActionE.AGM_EXTENSION: { + return isAllowedToFile(FilingTypes.AGM_EXTENSION) + } + + case AllowableActionE.AGM_LOCATION_CHANGE: { + return isAllowedToFile(FilingTypes.AGM_LOCATION_CHANGE) + } + + case AllowableActionE.AMALGAMATION: { + return isAllowedToFile(FilingTypes.AMALGAMATION_APPLICATION) + } + + case AllowableActionE.AMALGAMATION_OUT: { + return isAllowedToFile(FilingTypes.AMALGAMATION_OUT) + } + + case AllowableActionE.ANNUAL_REPORT: { + return isAllowedToFile(FilingTypes.ANNUAL_REPORT) + } + + case AllowableActionE.BUSINESS_INFORMATION: { + if (isLegalType([CorpTypeCd.COOP])) { + // NB: this feature is targeted via LaunchDarkly + const ff = !!getFeatureFlag('special-resolution-ui-enabled') + return (ff && isAllowedToFile(FilingTypes.SPECIAL_RESOLUTION)) + } + if (isEntityFirm()) { + return isAllowedToFile(FilingTypes.CHANGE_OF_REGISTRATION) + } + return isAllowedToFile(FilingTypes.ALTERATION) + } + + case AllowableActionE.BUSINESS_SUMMARY: { + // NB: specific entities are targeted via LaunchDarkly + const ff = !!getFeatureFlag('supported-business-summary-entities')?.includes(legalType) + return (ff && isBusiness) + } + + case AllowableActionE.CONSENT_AMALGAMATION_OUT: { + return isAllowedToFile(FilingTypes.CONSENT_AMALGAMATION_OUT) + } + + case AllowableActionE.CONSENT_CONTINUATION_OUT: { + return isAllowedToFile(FilingTypes.CONSENT_CONTINUATION_OUT) + } + + case AllowableActionE.CONTINUATION_OUT: { + return isAllowedToFile(FilingTypes.CONTINUATION_OUT) + } + + case AllowableActionE.CORRECTION: { + // NB: specific entities are targeted via LaunchDarkly + const ff = !!getFeatureFlag('supported-correction-entities')?.includes(legalType) + return (ff && isAllowedToFile(FilingTypes.CORRECTION)) + } + + case AllowableActionE.COURT_ORDER: { + return isAllowedToFile(FilingTypes.COURT_ORDER) + } + + case AllowableActionE.DETAIL_COMMENT: { + return (isBusiness && isStaffAccount) + } + + /** + * DBC feature is only available to self-registered owners of an SP + * who are logged in via BCSC. + */ + case AllowableActionE.DIGITAL_CREDENTIALS: { + // NB: this feature is targeted via LaunchDarkly + const ff = !!getFeatureFlag('enable-digital-credentials') + const isDigitalBusinessCardAllowed = currentBusiness.value.allowedActions.digitalBusinessCard + return (ff && isDigitalBusinessCardAllowed) + } + + case AllowableActionE.DIRECTOR_CHANGE: { + if (isEntityFirm()) { + return isAllowedToFile(FilingTypes.CHANGE_OF_REGISTRATION) + } + return isAllowedToFile(FilingTypes.CHANGE_OF_DIRECTORS) + } + + case AllowableActionE.FREEZE_UNFREEZE: { + // this covers both Freeze and Unfreeze + return isAllowedToFile(FilingTypes.ADMIN_FREEZE) + } + + case AllowableActionE.LIMITED_RESTORATION_EXTENSION: { + // NB: specific entities are targeted via LaunchDarkly + const ff = !!getFeatureFlag('supported-restoration-entities')?.includes(legalType) + return (ff && isAllowedToFile(FilingTypes.RESTORATION, FilingSubTypeE.LIMITED_RESTORATION_EXTENSION)) + } + + case AllowableActionE.LIMITED_RESTORATION_TO_FULL: { + // NB: specific entities are targeted via LaunchDarkly + const ff = !!getFeatureFlag('supported-restoration-entities')?.includes(legalType) + return (ff && isAllowedToFile(FilingTypes.RESTORATION, FilingSubTypeE.LIMITED_RESTORATION_TO_FULL)) + } + + case AllowableActionE.PUT_BACK_ON: { + // NB: specific entities are targeted via LaunchDarkly + const ff = !!getFeatureFlag('supported-put-back-on-entities')?.includes(legalType) + return (ff && isAllowedToFile(FilingTypes.PUT_BACK_ON)) + } + + case AllowableActionE.RECORD_CONVERSION: { + return isAllowedToFile(FilingTypes.CONVERSION) + } + + case AllowableActionE.REGISTRARS_NOTATION: { + return isAllowedToFile(FilingTypes.REGISTRARS_NOTATION) + } + + case AllowableActionE.REGISTRARS_ORDER: { + return isAllowedToFile(FilingTypes.REGISTRARS_ORDER) + } + + case AllowableActionE.RESTORATION: { + // NB: specific entities are targeted via LaunchDarkly + // NB: this applies to full restoration or limited restoration + // but not limited restoration extension or limited restoration to full + const ff = !!getFeatureFlag('supported-restoration-entities')?.includes(legalType) + return ( + ff && + ( + isAllowedToFile(FilingTypes.RESTORATION, FilingSubTypeE.FULL_RESTORATION) || + isAllowedToFile(FilingTypes.RESTORATION, FilingSubTypeE.LIMITED_RESTORATION) + ) + ) + } + + case AllowableActionE.STAFF_COMMENT: { + return (isBusiness && isStaffAccount) + } + + case AllowableActionE.TRANSITION: { + return isAllowedToFile(FilingTypes.TRANSITION) + } + + case AllowableActionE.VOLUNTARY_DISSOLUTION: { + // NB: specific entities are targeted via LaunchDarkly + const ff = !!getFeatureFlag('supported-dissolution-entities')?.includes(legalType) + return (ff && isAllowedToFile(FilingTypes.DISSOLUTION, FilingSubTypeE.DISSOLUTION_VOLUNTARY)) + } + + default: + return false // should never happen + } + } + + return { + isButtonForActionVisible: isAllowedToFile, + isActionVisible + } +})