forked from bcgov/business-create-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18535 - Add Amalgamating Businesses Part 1 (bcgov#585)
* 18535 - Add Amalgamating Businesses Part 1 * Fixed id name * Cleanup + added fix for new note * First set of fixes in response to Sev's comments * fixed lint error * Part fix in response to Sev's comments
- Loading branch information
1 parent
e4add08
commit 1eaa2d7
Showing
7 changed files
with
283 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
<template> | ||
<div id="amalgamating-businesses"> | ||
<v-btn | ||
id="btn-add-amalgamating-business" | ||
outlined | ||
color="primary" | ||
class="btn-outlined-primary" | ||
:disabled="isAddingAmalgamatingBusiness || isAddingAmalgamatingForeignBusiness" | ||
@click="onAddBusinessClick()" | ||
> | ||
<v-icon>mdi-domain-plus</v-icon> | ||
<span>Add an Amalgamating Business</span> | ||
</v-btn> | ||
|
||
<v-btn | ||
v-if="isRoleStaff" | ||
id="btn-add-amalgamating-foreign-business" | ||
outlined | ||
color="primary" | ||
class="ml-2 btn-outlined-primary" | ||
:disabled="isAddingAmalgamatingBusiness || isAddingAmalgamatingForeignBusiness" | ||
@click="onAddForeignBusinessClick()" | ||
> | ||
<v-icon>mdi-domain-plus</v-icon> | ||
<span>Add an Amalgamating Foreign Business</span> | ||
</v-btn> | ||
|
||
<!-- Add an Amalgamating Business button clicked --> | ||
<v-expand-transition> | ||
<v-card | ||
v-if="isAddingAmalgamatingBusiness" | ||
flat | ||
class="section-container mt-4 pr-0" | ||
> | ||
<v-row | ||
no-gutters | ||
> | ||
<v-col | ||
cols="12" | ||
sm="3" | ||
> | ||
<label>Add a Business Registered in BC</label> | ||
</v-col> | ||
|
||
<v-col | ||
cols="12" | ||
sm="8" | ||
class="ml-8" | ||
> | ||
<span>Enter the name or the incorporation number of the registered BC business | ||
to add to this application. | ||
</span> | ||
<BusinessLookup | ||
:showErrors="false" | ||
:businessLookup="initialBusinessLookupObject" | ||
:BusinessLookupServices="BusinessLookupServices" | ||
label="Business Name or Incorporation Number" | ||
@setBusiness="saveAmalgamatingBusiness($event)" | ||
/> | ||
<v-row | ||
class="justify-end mr-0 mt-2" | ||
> | ||
<v-btn | ||
id="app-cancel-btn" | ||
large | ||
outlined | ||
color="primary" | ||
@click="addAmalgamatingBusinessCancel()" | ||
> | ||
<span>Cancel</span> | ||
</v-btn> | ||
</v-row> | ||
</v-col> | ||
</v-row> | ||
</v-card> | ||
</v-expand-transition> | ||
|
||
<!-- Add an Amalgamating Foreign Business button clicked --> | ||
<v-expand-transition> | ||
<v-card | ||
v-if="isAddingAmalgamatingForeignBusiness" | ||
flat | ||
class="section-container mt-4" | ||
> | ||
<v-row | ||
no-gutters | ||
> | ||
<v-col | ||
cols="12" | ||
sm="3" | ||
> | ||
<label>Add a Foreign Business</label> | ||
</v-col> | ||
|
||
<v-col | ||
cols="12" | ||
sm="8" | ||
class="ml-8" | ||
> | ||
<span>**TODO**</span> | ||
</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 amalgamatingBusinesses" | ||
:key="index" | ||
> | ||
<template v-if="business.foundingDate"> | ||
Legal Name: {{ business.legalName }} <br> | ||
Legal Type: {{ business.legalType }} <br> | ||
Mailing Address: {{ business.officeAddress.mailingAddress }} <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> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Mixins } from 'vue-property-decorator' | ||
import { Action, Getter } from 'pinia-class' | ||
import { useStore } from '@/store/store' | ||
import { CommonMixin } from '@/mixins' | ||
import { BusinessLookupServices, LegalServices } from '@/services' | ||
import { BusinessLookup } from '@bcrs-shared-components/business-lookup' | ||
import { BusinessIF, BusinessLookupIF, EmptyBusinessLookup } from '@/interfaces' | ||
@Component({ | ||
components: { | ||
BusinessLookup | ||
} | ||
}) | ||
export default class AmalgamatingBusinesses extends Mixins(CommonMixin) { | ||
@Getter(useStore) getAmalgamatingBusinesses!: Array<BusinessIF> | ||
@Getter(useStore) isAmalgamationFilingHorizontal!: boolean | ||
@Getter(useStore) isRoleStaff!: boolean | ||
@Action(useStore) setAmalgamatingBusinesses!: (x: Array<BusinessIF>) => void | ||
// Local properties | ||
amalgamatingBusinessesValid = false | ||
amalgamatingBusinesses = [] | ||
initialBusinessLookupObject = EmptyBusinessLookup | ||
// Button properties | ||
isAddingAmalgamatingBusiness = false | ||
isAddingAmalgamatingForeignBusiness = false | ||
readonly BusinessLookupServices = BusinessLookupServices | ||
// Cancel button in "Add an Amalgamating Business" is pressed. | ||
addAmalgamatingBusinessCancel (): void { | ||
this.isAddingAmalgamatingBusiness = false | ||
} | ||
// "Add an Amalgamating Business" button is pressed. | ||
onAddBusinessClick (): void { | ||
this.isAddingAmalgamatingBusiness = true | ||
this.isAddingAmalgamatingForeignBusiness = false | ||
} | ||
// "Add an Amalgamating Foreign Business" button is pressed. | ||
onAddForeignBusinessClick (): void { | ||
this.isAddingAmalgamatingBusiness = false | ||
this.isAddingAmalgamatingForeignBusiness = true | ||
} | ||
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) | ||
.then((response) => { | ||
return response?.data?.business | ||
}).catch(() => { | ||
return businessLookup | ||
}) | ||
// Get the address of the amalgamating business | ||
if (businessLookup.identifier && business.foundingDate) { | ||
const addresses = await LegalServices.fetchAddresses(businessLookup.identifier) | ||
.then((data) => { | ||
// SP and GP have businessOffice instead of registeredOffice | ||
return data?.registeredOffice || data?.businessOffice | ||
}).catch(() => { | ||
return undefined | ||
}) | ||
if (addresses) { | ||
business.officeAddress = addresses | ||
} | ||
} | ||
// 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 (this.amalgamatingBusinesses.length > 0) { | ||
const businessExists = this.amalgamatingBusinesses.find(function (id) { | ||
return id.identifier === business.identifier | ||
}) | ||
if (!businessExists) this.amalgamatingBusinesses.push(business) | ||
} else { | ||
this.amalgamatingBusinesses.push(business) | ||
} | ||
// Set the amalgamated businesses array in the store. | ||
this.setAmalgamatingBusinesses(this.amalgamatingBusinesses) | ||
// Close the "Add an Amalgamating Business" Panel. | ||
this.addAmalgamatingBusinessCancel() | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import '@/assets/styles/theme.scss'; | ||
.v-btn:not(.v-btn--round).v-size--default { | ||
height: 44px; | ||
} | ||
</style> |
14 changes: 3 additions & 11 deletions
14
src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
import { AmalgamationTypes, ApprovalTypes, RelationshipTypes } from '@/enums' | ||
import { CourtOrderIF } from '@/interfaces' | ||
import { AmalgamationTypes } from '@/enums' | ||
import { BusinessIF } from '@/interfaces' | ||
|
||
export interface AmalgamationStateIF { | ||
applicationDate?: string // YYYY-MM-DD | ||
approvalType: ApprovalTypes | ||
approvalTypeValid: boolean | ||
businessNameValid: boolean | ||
courtOrder?: CourtOrderIF | ||
expiry?: string // YYYY-MM-DD | ||
noticeDate?: string // YYYY-MM-DD | ||
relationships?: RelationshipTypes[] | ||
restorationTypeValid: boolean | ||
amalgamatingBusinesses: Array<BusinessIF> | ||
type: AmalgamationTypes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.