Skip to content

Commit

Permalink
First set of fixes in response to Sev's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim committed Dec 1, 2023
1 parent 8bd7a04 commit 42d0c94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
25 changes: 10 additions & 15 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
:businessLookup="initialBusinessLookupObject"
:BusinessLookupServices="BusinessLookupServices"
label="Business Name or Incorporation Number"
@setBusiness="setAmalgamatingBusiness($event)"
@setBusiness="saveAmalgamatingBusiness($event)"
/>
<v-row
class="justify-end mr-0 mt-2"
Expand Down Expand Up @@ -192,17 +192,7 @@ export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
// this.addAmalgatingForeignBusinessDisabled = true
}
// Add to the amalgamating businesses array.
// If EP (A type), cannot be part of short form horizontal amalgamation.
pushToAmalgamatingBusinesses (business: any): void {
if (this.isAmalgamationFilingHorizontal) {
if (business.legalType !== 'A') this.amalgamatingBuinesses.push(business)
} else {
this.amalgamatingBuinesses.push(business)
}
}
async setAmalgamatingBusiness (businessLookup: BusinessLookupIF): Promise<void> {
async saveAmalgamatingBusiness (businessLookup: BusinessLookupIF): Promise<void> {
// Get the amalgamating business information
// Will have a different format depending on the business
let business = await LegalServices.fetchBusinessInfo(businessLookup.identifier)
Expand All @@ -229,12 +219,12 @@ export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
// 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.

This comment has been minimized.

Copy link
@severinbeauvais

severinbeauvais Dec 1, 2023

Collaborator

It would be better to refactor this to ensure the business is not already in the table BEFORE making all the network calls to fetch its data :)

if (this.amalgamatingBuinesses.length > 0) {
const filteredBusinesses = this.amalgamatingBuinesses.filter(function (id) {
const businessExists = this.amalgamatingBuinesses.find(function (id) {
return id.identifier === business.identifier
})
if (filteredBusinesses.length === 0) this.pushToAmalgamatingBusinesses(business)
if (!businessExists) this.amalgamatingBuinesses.push(business)
} else {
this.pushToAmalgamatingBusinesses(business)
this.amalgamatingBuinesses.push(business)
}
// Set the amalgamated businesses array in the store.
Expand All @@ -252,4 +242,9 @@ export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
height: 44px;
}
// Overriding the section container class right padding.

Check failure on line 245 in src/components/Amalgamation/AmalgamatingBusinesses.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Trailing spaces not allowed
.section-container {
padding-right: 0rem;
}
</style>
2 changes: 1 addition & 1 deletion src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ export const useStore = defineStore('store', {
return this.stateModel.restoration.approvalTypeValid
},

/** The amalgamting businesses. */
/** The amalgamating businesses. */
getAmalgamatingBusinesses (): Array<BusinessIF> {
return this.stateModel.amalgamation.amalgamatingBusinesses
},
Expand Down

0 comments on commit 42d0c94

Please sign in to comment.