Skip to content

Commit

Permalink
- app version = 5.6.11
Browse files Browse the repository at this point in the history
- imported latest BusinessLookup shared component
- updated fetchBusinessInfo return object
- simplified Amalg Businesses button and panel logic
- added Cancel button to Foreign panel
- added snackbar for save business errors
- deleted debugging template code
  • Loading branch information
Severin Beauvais committed Dec 11, 2023
1 parent 8a12a43 commit ca9746c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 101 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-create-ui",
"version": "5.6.10",
"version": "5.6.11",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand All @@ -17,7 +17,7 @@
"@bcrs-shared-components/approval-type": "1.0.19",
"@bcrs-shared-components/base-address": "2.0.3",
"@bcrs-shared-components/breadcrumb": "2.1.15",
"@bcrs-shared-components/business-lookup": "1.2.4",
"@bcrs-shared-components/business-lookup": "1.2.5",
"@bcrs-shared-components/certify": "2.1.15",
"@bcrs-shared-components/completing-party": "2.1.30",
"@bcrs-shared-components/confirm-dialog": "1.2.1",
Expand Down
6 changes: 2 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ import * as Views from '@/views'
// Mixins, interfaces, etc
import { CommonMixin, DateMixin, FilingTemplateMixin, NameRequestMixin } from '@/mixins'
import { AccountInformationIF, AddressIF, BreadcrumbIF, BusinessIF, BusinessWarningIF, CompletingPartyIF,
import { AccountInformationIF, AddressIF, BreadcrumbIF, BusinessWarningIF, CompletingPartyIF,
ConfirmDialogType, EmptyFees, FeesIF, FilingDataIF, NameRequestIF, OrgInformationIF, PartyIF, ResourceIF,
StepIF } from '@/interfaces'
import { AmalgamationRegResources, DissolutionResources, IncorporationResources, RegistrationResources,
Expand Down Expand Up @@ -1158,9 +1158,7 @@ export default class App extends Mixins(CommonMixin, DateMixin, FilingTemplateMi
/** Fetches and stores business info. */
private async loadBusinessInfo (businessId: string): Promise<void> {
const response = await LegalServices.fetchBusinessInfo(businessId)
const business = response?.data?.business as BusinessIF
const business = await LegalServices.fetchBusinessInfo(businessId).catch(() => {})
if (!business) {
throw new Error('Invalid business info')
Expand Down
159 changes: 75 additions & 84 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
color="primary"
class="btn-outlined-primary"
:disabled="isAddingAmalgamatingBusiness || isAddingAmalgamatingForeignBusiness"
@click="onAddBusinessClick()"
@click="isAddingAmalgamatingBusiness = true"
>
<v-icon>mdi-domain-plus</v-icon>
<span>Add an Amalgamating Business</span>
Expand All @@ -19,7 +19,7 @@
color="primary"
class="ml-2 btn-outlined-primary"
:disabled="isAddingAmalgamatingBusiness || isAddingAmalgamatingForeignBusiness"
@click="onAddForeignBusinessClick()"
@click="isAddingAmalgamatingForeignBusiness = true"
>
<v-icon>mdi-domain-plus</v-icon>
<span>Add an Amalgamating Foreign Business</span>
Expand All @@ -46,8 +46,8 @@
class="ml-8"
>
<span>Enter the name or the incorporation number of the registered BC business
to add to this application.
</span>
to add to this application.</span>

<BusinessLookup
:showErrors="false"
:businessLookup="initialBusinessLookupObject"
Expand All @@ -56,6 +56,7 @@
label="Business Name or Incorporation Number"
@setBusiness="saveAmalgamatingBusiness($event)"
/>

<v-row
class="justify-end mr-0 mt-2"
>
Expand All @@ -64,7 +65,7 @@
large
outlined
color="primary"
@click="addAmalgamatingBusinessCancel()"
@click="isAddingAmalgamatingBusiness = false"
>
<span>Cancel</span>
</v-btn>
Expand Down Expand Up @@ -95,37 +96,46 @@
class="ml-8"
>
<span>**TODO**</span>

<v-row
class="justify-end mr-0 mt-2"
>
<v-btn
id="app-cancel-btn"
large
outlined
color="primary"
@click="isAddingAmalgamatingForeignBusiness = false"
>
<span>Cancel</span>
</v-btn>
</v-row>
</v-col>

<!-- extra column is for possible action button -->
</v-row>
</v-card>
</v-expand-transition>

<!-- <v-row class="mt-4 ml-1">
<ul>
Amalgamating Businesses: <br><br>
<li
v-for="(business, index) in getAmalgamatingBusinesses"
:key="index"
<!-- snackbar to temporarily show fetch errors -->
<v-snackbar
v-model="snackbar"
timeout="5000"
>
{{ snackbarText }}

<template #action="{ attrs }">
<v-btn
color="error"
class="font-weight-bold"
text
v-bind="attrs"
@click="snackbar = false"
>
<template v-if="business.foundingDate">
Legal Name: {{ business.legalName }} <br>
Legal Type: {{ business.legalType }} <br>
Mailing Address: {{ business.officeAddress.registeredOffice.mailingAddress }} <br>
Email Address: {{ business.businessContact.email }} <br>
State: {{ business.state }} <br>
Good Standing: {{ business.goodStanding }} <br>
</template>
<template v-else>
Legal Name: {{ business.name }} <br>
Legal Type: {{ business.legalType }} <br>
Identifier: {{ business.identifier }} <br>
Status: {{ business.status }}
</template>
</li>
</ul>
</v-row> -->
Close
</v-btn>
</template>
</v-snackbar>

<BusinessTable
class="mt-8"
Expand Down Expand Up @@ -153,6 +163,8 @@ import BusinessTable from '@/components/Amalgamation/BusinessTable.vue'
}
})
export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
readonly BusinessLookupServices = BusinessLookupServices
@Getter(useStore) getAmalgamatingBusinesses!: AmalgamatingBusinessIF[]
@Getter(useStore) getAmalgamatingBusinessesValid!: boolean
@Getter(useStore) getShowErrors!: boolean
Expand All @@ -165,80 +177,59 @@ export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
// Local properties
initialBusinessLookupObject = EmptyBusinessLookup
businessTableValid = false
snackbar = false
snackbarText = ''
// Button properties
isAddingAmalgamatingBusiness = false
isAddingAmalgamatingForeignBusiness = false
readonly BusinessLookupServices = BusinessLookupServices
// Cancel button in "Add an Amalgamating Business" is pressed.
addAmalgamatingBusinessCancel (): void {
this.isAddingAmalgamatingBusiness = false
this.setAmalgamatingBusinessesValid(true)
}
// "Add an Amalgamating Business" button is pressed.
onAddBusinessClick (): void {
this.isAddingAmalgamatingBusiness = true
this.isAddingAmalgamatingForeignBusiness = false
this.setAmalgamatingBusinessesValid(false)
}
// "Add an Amalgamating Foreign Business" button is pressed.
onAddForeignBusinessClick (): void {
this.isAddingAmalgamatingBusiness = false
this.isAddingAmalgamatingForeignBusiness = true
this.setAmalgamatingBusinessesValid(false)
}
async saveAmalgamatingBusiness (businessLookup: BusinessLookupIF): Promise<void> {
let business = null
// Get the amalgamating business information, mailing address, and email if in LEAR.
// Get the amalgamating business information, auth info and addresses, and email if in LEAR.
// Otherwise, return the businesslookup object.
const data = await Promise.all([
LegalServices.fetchBusinessInfo(businessLookup.identifier),
AuthServices.fetchAuthInfo(businessLookup.identifier),
LegalServices.fetchAddresses(businessLookup.identifier)
]).catch((error) => {
return error
})
]).catch(() => {}) // ignore promise errors
if (data.length === 3) {
business = data[0].data?.business
business.businessContact = data[1].contacts[0]
business.officeAddress = data[2]
// check for errors
if (!data || data.length !== 3) {
this.snackbarText = 'Unable to add this business.'
this.snackbar = true
return
}
// If the business is not null (LEAR Entity), create from it a TING business following the interface.
// If the amalgamating businesses array is not empty, check if identifier already exists.
// If identifier already exists, don't add the business to the array.
if (business) {
const amalgamatingBusinesses = this.getAmalgamatingBusinesses
const tingBusiness = {
type: 'lear',
role: AmlRoles.AMALGAMATING,
identifier: business.identifier,
name: business.legalName,
email: business.businessContact.email,
legalType: business.legalType,
address: business.officeAddress.registeredOffice.mailingAddress,
goodStanding: business.goodStanding
} as AmalgamatingBusinessIF
const businessInfo = data[0]
const authInfo = data[1]
const addresses = data[2]
if (!amalgamatingBusinesses.find((b: any) => b.identifier === business.identifier)) {
amalgamatingBusinesses.push(tingBusiness)
// Set the new amalgamated businesses array in the store.
this.setAmalgamatingBusinesses(amalgamatingBusinesses)
}
// If identifier already exists, don't add the business to the array.
if (this.getAmalgamatingBusinesses.find((b: any) => b.identifier === businessInfo.identifier)) {
this.snackbarText = 'Business is already in table.'
this.snackbar = true
return
}
// Close the "Add an Amalgamating Business" Panel.
// Create amalgamating business object.
const tingBusiness = {
type: 'lear',
role: AmlRoles.AMALGAMATING,
identifier: businessInfo.identifier,
name: businessInfo.legalName,
email: authInfo.contacts[0].email,
legalType: businessInfo.legalType,
address: addresses.registeredOffice.mailingAddress,
goodStanding: businessInfo.goodStanding
} as AmalgamatingBusinessIF
// Add the new business to a new array and store the new array.
const amalgamatingBusinesses = this.getAmalgamatingBusinesses
amalgamatingBusinesses.push(tingBusiness)
this.setAmalgamatingBusinesses(amalgamatingBusinesses)
// Close the "Add an Amalgamating Business" panel.
this.isAddingAmalgamatingBusiness = false
this.setAmalgamatingBusinessesValid(true)
}
/** Sets validity according to various flags. */
Expand Down
14 changes: 9 additions & 5 deletions src/services/legal-services.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AxiosInstance as axios } from '@/utils'
import { StatusCodes } from 'http-status-codes'
import { AmalgamationFilingIF, DissolutionFilingIF, IncorporationFilingIF, NameRequestIF, RegistrationFilingIF,
RestorationFilingIF } from '@/interfaces'
import { AmalgamationFilingIF, BusinessIF, DissolutionFilingIF, IncorporationFilingIF, NameRequestIF,
RegistrationFilingIF, RestorationFilingIF } from '@/interfaces'
import { FilingTypes } from '@/enums'

/**
Expand Down Expand Up @@ -175,10 +175,14 @@ export default class LegalServices {
/**
* Fetches business info.
* @param businessId the business identifier
* @returns a promise to return the info from the response, else exception
* @returns a promise to return the business info, else exception
*/
static async fetchBusinessInfo (businessId: string): Promise<any> {
static async fetchBusinessInfo (businessId: string): Promise<BusinessIF> {
const url = `businesses/${businessId}`
return axios.get(url)
return axios.get(url).then(response => {
const data = response?.data
if (!data) throw new Error('Invalid API response')
return data.business
})
}
}

0 comments on commit ca9746c

Please sign in to comment.