Skip to content

Commit

Permalink
Custodian of Records section (#9)
Browse files Browse the repository at this point in the history
* Custodian of Records accordion for historical businesses

* clean-up and minor i18n tweak
  • Loading branch information
patrickpeinanw authored Jun 26, 2024
1 parent 1dc3f50 commit e7176eb
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 29 deletions.
12 changes: 12 additions & 0 deletions cypress/e2e/components/custodian-of-records.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
context('Business dashboard -> Custodian of Records components', () => {
it('Custodian accordion is rendered for historical business', () => {
// when parties contain a person with 'Custodian' role and the business is historical
cy.visitBusinessDash('BC0871427', 'BEN', true)
cy.get('[data-cy="accordion_custodian"]').should('exist')
cy.get('[data-cy="accordion_custodian"]').children().eq(0).children().should('have.length', 1)

// non-historical business with no custodian of records
cy.visitBusinessDash('BC0871427', 'BEN', false)
cy.get('[data-cy="accordion_custodian"]').should('not.exist')
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
context('Business dashboard -> Parties side components', () => {
context('Business dashboard -> Side components: Current Directors, Partners, Proprietors', () => {
it('Directors accordion is rendered', () => {
cy.visitBusinessDash('BC0871427', 'BEN')
cy.get('[data-cy="accordion_directors"]').should('exist')
Expand Down
36 changes: 36 additions & 0 deletions cypress/fixtures/custodianOfRecords.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"deliveryAddress": {
"addressCity": "Burnaby",
"addressCountry": "CA",
"addressRegion": "BC",
"deliveryInstructions": "",
"id": 2902982,
"postalCode": "V5E 3X4",
"streetAddress": "7861 Welsley Dr",
"streetAddressAdditional": ""
},
"mailingAddress": {
"addressCity": "Burnaby",
"addressCountry": "CA",
"addressRegion": "BC",
"deliveryInstructions": "",
"id": 2902983,
"postalCode": "V5E 3X4",
"streetAddress": "7861 Welsley Dr",
"streetAddressAdditional": ""
},
"officer": {
"email": "vishnupreddy0422@gmail.com",
"firstName": "VISH",
"id": 584259,
"lastName": "P",
"partyType": "person"
},
"roles": [
{
"appointmentDate": "2024-06-19",
"cessationDate": null,
"roleType": "Custodian"
}
]
}
26 changes: 17 additions & 9 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Cypress.Commands.add('interceptBusinessSlim', (identifier, legalType) => {
Cypress.Commands.add('interceptBusinessSlim', (identifier, legalType, isHistorical) => {
cy.fixture(`business${legalType}`).then((business) => {
business.identifier = identifier
if (isHistorical) {
business.state = 'HISTORICAL'
}
cy.intercept(
'GET',
`**/api/v2/businesses/${business.identifier}?slim=true`,
Expand Down Expand Up @@ -35,7 +38,7 @@ Cypress.Commands.add('interceptAddresses', (legalType) => {
})
})

Cypress.Commands.add('interceptParties', (legalType) => {
Cypress.Commands.add('interceptParties', (legalType, hasCustodian = false) => {
let partyFixture = 'directorParties'

if (legalType === 'SP') {
Expand All @@ -45,14 +48,19 @@ Cypress.Commands.add('interceptParties', (legalType) => {
}

cy.fixture(partyFixture).then((parties) => {
cy.intercept(
'GET',
'**/api/v2/businesses/**/parties*',
parties)
cy.fixture('custodianOfRecords').then((custodian) => {
if (hasCustodian) {
parties.parties.push(custodian)
}
cy.intercept(
'GET',
'**/api/v2/businesses/**/parties*',
parties)
})
})
})

Cypress.Commands.add('visitBusinessDash', (identifier = 'BC0871427', legalType = 'BEN') => {
Cypress.Commands.add('visitBusinessDash', (identifier = 'BC0871427', legalType = 'BEN', isHistorical = false) => {
sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true')
cy.intercept('GET', '**/api/v1/users/**/settings', { fixture: 'settings.json' }).as('getSettings')
cy.intercept(
Expand All @@ -62,9 +70,9 @@ Cypress.Commands.add('visitBusinessDash', (identifier = 'BC0871427', legalType =
).as('getLdarklyContext')
cy.intercept('GET', '**/api/v1/orgs/**/products*', { fixture: 'products.json' }).as('getProducts')
cy.interceptBusinessContact(identifier, legalType).as('getBusinessContact')
cy.interceptBusinessSlim(identifier, legalType).as('getBusinessSlim')
cy.interceptBusinessSlim(identifier, legalType, isHistorical).as('getBusinessSlim')
cy.interceptAddresses(legalType).as('getAddresses')
cy.interceptParties(legalType).as('getParties')
cy.interceptParties(legalType, isHistorical).as('getParties')

cy.visit(`/${identifier}`)
cy.wait(['@getSettings', '@getProducts', '@getBusinessContact', '@getBusinessSlim', '@getAddresses', '@getParties'])
Expand Down
4 changes: 2 additions & 2 deletions src/components/bcros/AccordionItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :data-cy="'accordion-item_' + name" class="flex flex-col pl-3">
<div :data-cy="'accordion-item_' + name" class="flex flex-col pl-3 pb-3">
<div v-if="item.showEmail" class="flex flex-col w-3/4 ml-10 pb-3">
<div class="text-gray-900 pb-1">
{{ $t('label.general.email') }}
Expand All @@ -8,7 +8,7 @@
{{ item.email }}
</span>
<span v-else>
{{ `(Not entered)` }}
{{ $t('text.general.notEntered') }}
</span>
</div>
<BcrosAddress
Expand Down
9 changes: 5 additions & 4 deletions src/components/bcros/OfficeAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const t = useNuxtApp().$i18n.t
const business = useBcrosBusiness()
const { currentBusinessAddresses } = storeToRefs(business)
defineProps({
name: { type: String, required: true }
const props = defineProps({
name: { type: String, required: true },
expandTopItem: { type: Boolean, default: false }
})
const showBusinessOffice = computed(() => {
Expand All @@ -38,7 +39,7 @@ const addressItems = computed(() => {
if (currentBusinessAddresses.value.registeredOffice) {
items.push({
label: t('label.address.officeType.registered'),
defaultOpen: true,
defaultOpen: props.expandTopItem,
showAddressIcons: true,
showAvatar: false,
showEmail: false,
Expand All @@ -49,7 +50,7 @@ const addressItems = computed(() => {
if (currentBusinessAddresses.value.recordsOffice) {
items.push({
label: t('label.address.officeType.records'),
defaultOpen: !currentBusinessAddresses.value.registeredOffice,
defaultOpen: props.expandTopItem && !currentBusinessAddresses.value.registeredOffice,
showAddressIcons: true,
showAvatar: false,
showEmail: false,
Expand Down
8 changes: 7 additions & 1 deletion src/components/bcros/PartyInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const { currentParties } = storeToRefs(business)
const props = defineProps({
name: { type: String, required: true },
roleType: { type: String, required: true },
showEmail: { type: Boolean, required: true }
showEmail: { type: Boolean, required: true },
expandTopItem: { type: Boolean, default: false }
})
const partyItems = computed(() => {
Expand All @@ -38,6 +39,11 @@ const partyItems = computed(() => {
}
})
}
if (items.length > 0 && props.expandTopItem) {
items[0].defaultOpen = true
}
return items
})
Expand Down
9 changes: 5 additions & 4 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"label": {
"general": {
"email": "Email",
"phone": "Phone",
"notEntered": "Not entered"
"phone": "Phone"
},
"business": {
"businessNum": "Business Number",
Expand Down Expand Up @@ -62,7 +61,8 @@
"text": {
"general": {
"nA": "Not Available",
"saveAsAbove": "Same as above"
"saveAsAbove": "Same as above",
"notEntered": "(Not entered)"
},
"dialog": {
"error": {
Expand Down Expand Up @@ -95,7 +95,8 @@
"officeAddresses": "Office Addresses",
"currentDirectors": "Current Directors",
"partners": "Partners",
"proprietors": "Proprietors"
"proprietors": "Proprietors",
"custodianOfRecords": "Custodian of Records"
}
}
}
33 changes: 28 additions & 5 deletions src/pages/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@
</div>

<div class="w-full pt-5 md:w-3/12 md:pl-5 md:pt-0 flex flex-col">
<BcrosSection name="address">
<BcrosSection v-if="showCustodian" name="custodian">
<template #header>
<div class="flex justify-between">
<span>
{{ $t('title.section.custodianOfRecords') }}
</span>
</div>
</template>
<BcrosPartyInfo name="custodian" :role-type="RoleTypeE.CUSTODIAN" :show-email="false" :expand-top-item="true" />
</BcrosSection>

<BcrosSection name="address" :class="showCustodian ? 'pt-5' : ''">
<template #header>
<div class="flex justify-between">
<span v-if="currentBusinessAddresses.businessOffice">
Expand All @@ -37,7 +48,7 @@
/>
</div>
</template>
<BcrosOfficeAddress name="officeAddresses" />
<BcrosOfficeAddress name="officeAddresses" :expand-top-item="!showCustodian" />
</BcrosSection>

<BcrosSection v-if="hasDirector" name="directors" class="pt-5">
Expand Down Expand Up @@ -111,7 +122,7 @@ import { storeToRefs } from 'pinia'
const route = useRoute()
const business = useBcrosBusiness()
const { currentBusinessAddresses } = storeToRefs(business)
const { currentBusinessAddresses, currentBusiness } = storeToRefs(business)
const hasDirector = computed(() => {
if (business.currentParties.parties && business.currentParties.parties.length > 0) {
Expand All @@ -134,20 +145,32 @@ const hasProprietor = computed(() => {
return false
})
const hasCustodian = computed(() => {
if (business.currentParties.parties && business.currentParties.parties.length > 0) {
return containRole(RoleTypeE.CUSTODIAN)
}
return false
})
const showCustodian = computed(() => {
return hasCustodian.value && currentBusiness.value.state === BusinessStateE.HISTORICAL
})
// check if the business has a party that has a certain role type
const containRole = (roleType) => {
return business.currentParties.parties.find(party =>
party.roles.find(role => role.roleType === roleType && !role.cessationDate)
)
}
const loadAddressesAndParties = () => {
const loadBusinessInfo = () => {
if (route.params.identifier) {
business.loadBusinessAddresses(route.params.identifier as string)
business.loadParties(route.params.identifier as string)
business.loadBusiness(route.params.identifier as string)
}
}
onBeforeMount(() => {
loadAddressesAndParties()
loadBusinessInfo()
})
</script>
2 changes: 1 addition & 1 deletion src/utils/error-dialog-options/auth-access-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getAuthAccessError(): DialogOptionsI {
{
onClick: useBcrosNavigate().goToBcrosDashboard,
onClickClose: true,
text: t('label.general.ok')
text: t('button.general.ok')
}
],
onClose: useBcrosNavigate().goToBcrosDashboard,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/error-dialog-options/default-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getDefaultError(): DialogOptionsI {
{
onClick: useBcrosNavigate().goToBcrosDashboard,
onClickClose: true,
text: t('label.general.ok')
text: t('button.general.ok')
}
],
onClose: useBcrosNavigate().goToBcrosDashboard,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/error-dialog-options/download-file-error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function getDownloadFileError(): DialogOptionsI {
const t = useNuxtApp().$i18n.t
return {
buttons: [{ onClickClose: true, text: t('label.general.ok') }],
buttons: [{ onClickClose: true, text: t('button.general.ok') }],
text: t('text.dialog.error.download'),
title: t('title.dialog.error.download')
}
Expand Down

0 comments on commit e7176eb

Please sign in to comment.