diff --git a/business-registry-dashboard/app/components/DashboardContent.vue b/business-registry-dashboard/app/components/DashboardContent.vue new file mode 100644 index 0000000..6b8c6e8 --- /dev/null +++ b/business-registry-dashboard/app/components/DashboardContent.vue @@ -0,0 +1,6 @@ + diff --git a/business-registry-dashboard/app/layouts/dashboard.vue b/business-registry-dashboard/app/layouts/dashboard.vue index f766ea8..a34b95d 100644 --- a/business-registry-dashboard/app/layouts/dashboard.vue +++ b/business-registry-dashboard/app/layouts/dashboard.vue @@ -5,12 +5,15 @@ const config = useRuntimeConfig().public const { isAuthenticated } = useKeycloak() useHead({ - title: t('page.home.title') + title: accountStore.isStaffOrSbcStaff ? t('page.home.titleStaff') : t('page.home.title') }) setBreadcrumbs([ - { to: `${config.registryHomeURL}dashboard?accountid=${accountStore.currentAccount.id}`, label: t('labels.bcRegDashboard') }, - { label: t('page.home.h1') } + { + to: `${config.registryHomeURL}dashboard?accountid=${accountStore.currentAccount.id}`, + label: accountStore.isStaffOrSbcStaff ? t('labels.bcRegStaffDashboard') : t('labels.bcRegDashboard') + }, + { label: accountStore.isStaffOrSbcStaff ? t('page.home.h1Staff') : t('page.home.h1') } ]) onMounted(() => { @@ -28,7 +31,7 @@ onMounted(() => {

- {{ $t('page.home.h1') }} + {{ accountStore.isStaffOrSbcStaff ? t('page.home.h1Staff') : t('page.home.h1') }}

diff --git a/business-registry-dashboard/app/locales/en-CA.ts b/business-registry-dashboard/app/locales/en-CA.ts index 437d4bc..39fdf0f 100644 --- a/business-registry-dashboard/app/locales/en-CA.ts +++ b/business-registry-dashboard/app/locales/en-CA.ts @@ -496,7 +496,8 @@ export default { resendEmail: 'Resend Email', removeFromList: 'Remove From List', removeBusiness: 'Remove Business', - bcRegDashboard: 'BC Registries Dashboard' + bcRegDashboard: 'BC Registries Dashboard', + bcRegStaffDashboard: 'Staff Dashboard' }, links: { busCorpAct: { @@ -610,7 +611,9 @@ export default { }, home: { title: 'My Business Registry', + titleStaff: 'My Staff Business Registry', h1: 'My Business Registry', + h1Staff: 'My Staff Business Registry', intro: 'Start B.C. based businesses and keep business records up to date.', busOrNRSearch: { label: 'Retrieve an existing business or active Name Request to manage:', diff --git a/business-registry-dashboard/app/locales/fr-CA.ts b/business-registry-dashboard/app/locales/fr-CA.ts index fe5a9c4..a1544b9 100644 --- a/business-registry-dashboard/app/locales/fr-CA.ts +++ b/business-registry-dashboard/app/locales/fr-CA.ts @@ -486,7 +486,8 @@ export default { resendEmail: 'Renvoyer le Courriel', removeFromList: 'Supprimer de la Liste', removeBusiness: "Supprimer l'Entreprise", - bcRegDashboard: 'Tableau de Bord des Registres de la CB' + bcRegDashboard: 'Tableau de Bord des Registres de la CB', + bcRegStaffDashboard: 'Tableau de Bord du Personnel' }, links: { busCorpAct: { @@ -600,7 +601,9 @@ export default { }, home: { title: "Mon Registre d'Entreprise", + titleStaff: 'Registre des Entreprises de mon Personnel', h1: "Mon Registre d'Entreprise", + h1Staff: 'Registre des Entreprises de mon Personnel', intro: 'Commencer la CB entreprises basées et tenir à jour les dossiers commerciaux.', busOrNRSearch: { label: 'Rechercher une Entreprise Existante ou une Demande de Nom Active à Gérer:', diff --git a/business-registry-dashboard/app/middleware/01.account-link.global.ts b/business-registry-dashboard/app/middleware/01.account-link.global.ts new file mode 100644 index 0000000..8951e2a --- /dev/null +++ b/business-registry-dashboard/app/middleware/01.account-link.global.ts @@ -0,0 +1,12 @@ +export default defineNuxtRouteMiddleware((to) => { + // Check if the route is an account link without locale prefix + if (to.path.startsWith('/account')) { + // Construct the full URL with the en-CA locale prefix + const newUrl = `/en-CA${to.path}` + // Force a full page reload with the new URL to ensure proper locale handling + window.location.href = newUrl + + // Prevent Nuxt from handling the navigation since we're doing a full page reload + return abortNavigation() + } +}) diff --git a/business-registry-dashboard/app/middleware/01.auth.global.ts b/business-registry-dashboard/app/middleware/02.auth.global.ts similarity index 100% rename from business-registry-dashboard/app/middleware/01.auth.global.ts rename to business-registry-dashboard/app/middleware/02.auth.global.ts diff --git a/business-registry-dashboard/app/pages/[...slug].vue b/business-registry-dashboard/app/pages/[...slug].vue new file mode 100644 index 0000000..604f5d2 --- /dev/null +++ b/business-registry-dashboard/app/pages/[...slug].vue @@ -0,0 +1,10 @@ + + + diff --git a/business-registry-dashboard/app/pages/account/[orgId].vue b/business-registry-dashboard/app/pages/account/[orgId].vue new file mode 100644 index 0000000..32ba408 --- /dev/null +++ b/business-registry-dashboard/app/pages/account/[orgId].vue @@ -0,0 +1,5 @@ + diff --git a/business-registry-dashboard/app/pages/affiliationInvitation/acceptToken.vue b/business-registry-dashboard/app/pages/affiliationInvitation/acceptToken.vue index ee727fe..51bda54 100644 --- a/business-registry-dashboard/app/pages/affiliationInvitation/acceptToken.vue +++ b/business-registry-dashboard/app/pages/affiliationInvitation/acceptToken.vue @@ -77,9 +77,6 @@ const parseUrlAndAddAffiliation = async (token: any, base64Token: string) => { diff --git a/business-registry-dashboard/app/pages/incorporateNow.vue b/business-registry-dashboard/app/pages/incorporateNow.vue index c3f0c05..5031297 100644 --- a/business-registry-dashboard/app/pages/incorporateNow.vue +++ b/business-registry-dashboard/app/pages/incorporateNow.vue @@ -127,8 +127,7 @@ onMounted(async () => {

diff --git a/business-registry-dashboard/app/pages/index.vue b/business-registry-dashboard/app/pages/index.vue index 1f45e20..a5fc028 100644 --- a/business-registry-dashboard/app/pages/index.vue +++ b/business-registry-dashboard/app/pages/index.vue @@ -5,9 +5,6 @@ definePageMeta({ diff --git a/business-registry-dashboard/app/stores/affiliations.ts b/business-registry-dashboard/app/stores/affiliations.ts index 65f1fb3..4450caf 100644 --- a/business-registry-dashboard/app/stores/affiliations.ts +++ b/business-registry-dashboard/app/stores/affiliations.ts @@ -136,7 +136,18 @@ export const useAffiliationsStore = defineStore('brd-affiliations-store', () => affiliations.loading = true if (!accountStore.currentAccount.id || !$keycloak.authenticated) { return } - const response = await $authApi<{ entities: AffiliationResponse[] }>(`/orgs/${accountStore.currentAccount.id}/affiliations?new=true`) + + const route = useRoute() + // Use route param if staff, otherwise use current account + const orgId = (isStaffOrSbcStaff.value && route.params.orgId) + ? route.params.orgId + : accountStore.currentAccount.id + + if (!orgId) { return } + + const response = await $authApi<{ entities: AffiliationResponse[] }>( + `/orgs/${orgId}/affiliations?new=true` + ) let affiliatedEntities: Business[] = [] diff --git a/business-registry-dashboard/package.json b/business-registry-dashboard/package.json index f11d1cf..a701c5c 100644 --- a/business-registry-dashboard/package.json +++ b/business-registry-dashboard/package.json @@ -2,7 +2,7 @@ "name": "business-registry-dashboard", "private": true, "type": "module", - "version": "0.0.14", + "version": "0.0.15", "scripts": { "build-check": "nuxt build", "build": "nuxt generate", diff --git a/business-registry-dashboard/tests/unit/pages/index.test.ts b/business-registry-dashboard/tests/unit/pages/index.test.ts index 523aa5d..cabf63c 100644 --- a/business-registry-dashboard/tests/unit/pages/index.test.ts +++ b/business-registry-dashboard/tests/unit/pages/index.test.ts @@ -1,6 +1,6 @@ import { mountSuspended } from '@nuxt/test-utils/runtime' import { describe, it, expect } from 'vitest' -import { BusinessLookup, TableAffiliatedEntity } from '#components' +import { DashboardContent } from '#components' import Dashboard from '~/layouts/dashboard.vue' import { enI18n } from '~~/tests/mocks/i18n' import Index from '~/pages/index.vue' @@ -26,7 +26,6 @@ describe('Index Page', () => { it('should render child components correctly', async () => { const wrapper = await mountPage() - expect(wrapper.findComponent(BusinessLookup).exists()).toBe(true) - expect(wrapper.findComponent(TableAffiliatedEntity).exists()).toBe(true) + expect(wrapper.findComponent(DashboardContent).exists()).toBe(true) }) }) diff --git a/business-registry-dashboard/tests/unit/stores/affiliations.test.ts b/business-registry-dashboard/tests/unit/stores/affiliations.test.ts index 495d653..7a8a797 100644 --- a/business-registry-dashboard/tests/unit/stores/affiliations.test.ts +++ b/business-registry-dashboard/tests/unit/stores/affiliations.test.ts @@ -145,6 +145,12 @@ mockNuxtImport('useConnectLaunchdarklyStore', () => { ) }) +// Add mock for useRoute +const mockRoute = { params: {} } +mockNuxtImport('useRoute', () => { + return () => mockRoute +}) + describe('useAffiliationsStore', () => { let store: any @@ -169,6 +175,7 @@ describe('useAffiliationsStore', () => { vi.clearAllMocks() vi.resetAllMocks() mockAuthenticated = true + mockRoute.params = {} // Reset route params after each test }) describe('loadAffiliations', () => { @@ -183,11 +190,33 @@ describe('useAffiliationsStore', () => { const affStore = useAffiliationsStore() await affStore.loadAffiliations() + await flushPromises() + + // Should use accountStore.currentAccount.id since not staff + expect(mockAuthApi).toHaveBeenCalledWith('/orgs/123/affiliations?new=true') + // results mapped to business object + expect(affStore.affiliations.results).toEqual(processedAffiliations) + expect(affStore.affiliations.count).toEqual(4) + }) + + it('should use route param orgId when user is staff', async () => { + store.currentAccount.accountType = 'STAFF' // Make user staff + mockRoute.params = { orgId: '456' } // Set route param - // wait for getAffiliatedEntities to finish + mockGetStoredFlag.mockReturnValue(true) + mockAuthApi + .mockResolvedValueOnce(mockEntities) + .mockResolvedValueOnce({ + affiliationInvitations: [] + }) + + const affStore = useAffiliationsStore() + + await affStore.loadAffiliations() await flushPromises() - expect(mockAuthApi).toHaveBeenCalledTimes(2) // once for affiliations and another for invitations + // Should use route.params.orgId since user is staff + expect(mockAuthApi).toHaveBeenCalledWith('/orgs/456/affiliations?new=true') // results mapped to business object expect(affStore.affiliations.results).toEqual(processedAffiliations) expect(affStore.affiliations.count).toEqual(4)