Skip to content

Commit

Permalink
24205 - updates for name change and alteration (bcgov#784)
Browse files Browse the repository at this point in the history
* 24205 - updates for name change and alteration ff

* 24205 - remove feature flags

* 24205 - remove feature flags

* 24205 - update version

* 24205 - remove unsused import

* 24205 - remove consitional chaining

* 24205 - update funstions

* 24205

* 24205

* 24205- update mounted() with async
  • Loading branch information
ketaki-deodhar authored and meawong committed Jan 3, 2025
1 parent 496d0dd commit 9fec1a3
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "name-request",
"version": "5.5.12",
"version": "5.5.13",
"private": true,
"appName": "Name Request UI",
"sbcName": "SBC Common Components",
Expand Down
14 changes: 12 additions & 2 deletions app/src/components/existing-request/nr-approved-gray-box.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ export default class NrApprovedGrayBox extends Mixins(CommonMixin) {
@Prop({ default: false }) readonly disabled!: boolean
@Getter getNr!: Partial<NameRequestI>
@Getter getIsLearBusiness!: boolean
isBusinesCheckDone = false
/** Called when component is mounted. */
async mounted () {
// check if business is in Lear and set store value of isLearBusiness flag
await this.checkBusinessInLear(this.getNr?.corpNum)
}
get isConversion (): boolean {
return (this.getNr.request_action_cd === NrRequestActionCodes.CONVERSION)
Expand Down Expand Up @@ -300,9 +309,9 @@ export default class NrApprovedGrayBox extends Mixins(CommonMixin) {
get showOpenExternalIcon (): boolean {
if (this.showAmalgamateNowButton && !this.isSupportedAmalgamation(this.getNr.entity_type_cd)) return true
if (this.showAlterNowButton && !this.isSupportedAlteration(this.getNr.requestTypeCd)) return true
if (this.showAlterNowButton && !this.getIsLearBusiness) return true
if (this.showBeginContinuationButton && !this.isSupportedContinuationIn(this.getNr.entity_type_cd)) return true
if (this.showNameChangeButton && !this.isSupportedChangeName(this.getNr.entity_type_cd)) return true
if (this.showNameChangeButton && !this.getIsLearBusiness) return true
return false
}
Expand Down Expand Up @@ -335,6 +344,7 @@ export default class NrApprovedGrayBox extends Mixins(CommonMixin) {
)
}
}
</script>

<style lang="scss" scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export default class BusinessLookupFetch extends Mixins(CommonMixin, SearchMixin
if (this.getSearchBusiness) {
// set the from business for alteration (conversion)
this.setOriginEntityTypeCd(this.getSearchBusiness.legalType)
// check if business is in Lear and set store value of isLearBusiness flag
await this.checkBusinessInLear(this.getSearchBusiness.identifier)
} else {
// clear all related fields when clearing business search/fetch for alter
this.setConversionType(null)
Expand Down Expand Up @@ -159,6 +161,9 @@ export default class BusinessLookupFetch extends Mixins(CommonMixin, SearchMixin
const corpType = this.getSearchBusiness.legalType as unknown as CorpTypeCd
this.setEntityTypeCd(this.corpTypeToEntityType(corpType) || this.getSearchBusiness.legalType)
}
// check if business is in Lear and set store value of isLearBusiness flag
await this.checkBusinessInLear(this.getSearchBusiness.identifier)
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions app/src/components/new-request/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ import { CommonMixin, NrAffiliationMixin, SearchMixin } from '@/mixins'
import { Designations, XproMapping } from '@/list-data'
import { Navigate } from '@/plugins'
import { ActionBindingIF } from '@/interfaces/store-interfaces'
import { Action } from 'vuex-class'
import { Action, Getter } from 'vuex-class'
/**
* This is the component that displays the new NR menus and flows.
Expand All @@ -420,6 +420,8 @@ import { Action } from 'vuex-class'
export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, SearchMixin) {
@Action setSocietiesModalVisible!: ActionBindingIF
@Getter getIsLearBusiness!: boolean
// Constant
readonly colinLink = sessionStorage.getItem('CORPORATE_ONLINE_URL')
Expand Down Expand Up @@ -529,7 +531,7 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
this.isConversion &&
this.isNumberedCompany &&
this.isAlterOnline(this.getConversionType) &&
this.isSupportedAlteration(this.getConversionType)
this.getIsLearBusiness
) return true
// Conditional for "New BC-based business" Flow.
Expand All @@ -542,7 +544,7 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
// Conditional for Change Name Flow.
if (this.isChangeName &&
this.isNumberedCompany &&
this.isSupportedChangeName(this.getEntityTypeCd)
this.getIsLearBusiness
) return true
// Conditional for Restoration/Reinstatement Flow.
Expand All @@ -569,7 +571,7 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
if (
this.isConversion &&
this.isNumberedCompany &&
!this.isSupportedAlteration(this.getConversionType) &&
!this.getIsLearBusiness &&
this.isAlterOnline(this.getConversionType)
) return true
Expand All @@ -586,7 +588,7 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
if (
this.isChangeName &&
this.isNumberedCompany &&
!this.isSupportedChangeName(this.getEntityTypeCd)
!this.getIsLearBusiness
) return true
// Conditional for Change Name XPRO Flow.
Expand Down
1 change: 1 addition & 0 deletions app/src/interfaces/new-request-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface NewRequestIF {
getNameReservationFailed: boolean
helpMeChooseModalVisible: boolean
hotjarUserId: string,
isLearBusiness: boolean
isLoadingSubmission: boolean
isPersonsName: boolean
issueIndex: number
Expand Down
32 changes: 20 additions & 12 deletions app/src/mixins/common-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ import { Component, Vue } from 'vue-property-decorator'
import { EntityTypes, PriorityCode, NrRequestActionCodes, NrRequestTypeCodes } from '@/enums'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'
import { GetFeatureFlag } from '@/plugins'
import { Action, Getter } from 'vuex-class'
import BusinessServices from '@/services/business-services'
import { BusinessSearchIF } from '@/interfaces'
import { ActionBindingIF } from '@/interfaces/store-interfaces'

@Component({})
export class CommonMixin extends Vue {
@Getter getSearchBusiness!: BusinessSearchIF

@Action setIsLearBusiness!: ActionBindingIF

/** True if Jest is running the code. */
get isJestRunning (): boolean {
return (process.env.JEST_WORKER_ID !== undefined)
Expand Down Expand Up @@ -197,24 +205,12 @@ export class CommonMixin extends Vue {
return supportedEntites.includes(type)
}

/** Returns true if the specified request type is allowed for alteration (conversion). */
isSupportedAlteration (type: NrRequestTypeCodes): boolean {
const supportedAlterationTypes = GetFeatureFlag('supported-alteration-types')
return supportedAlterationTypes.includes(type)
}

/** Returns true if the specified entity type is allowed for amalgamation. */
isSupportedAmalgamation (type: EntityTypes): boolean {
const supportedAmalgamationEntities = GetFeatureFlag('supported-amalgamation-entities')
return supportedAmalgamationEntities.includes(type)
}

/** Returns true if the specified entity type is allowed for name change. */
isSupportedChangeName (type: EntityTypes): boolean {
const supportedChangeNameEntities = GetFeatureFlag('supported-name-change-entities')
return supportedChangeNameEntities.includes(type)
}

/** Returns true if the specified entity type is allowed for continuation in. */
isSupportedContinuationIn (type: EntityTypes): boolean {
const supportedContInEntites = GetFeatureFlag('supported-continuation-in-entities')
Expand All @@ -240,6 +236,18 @@ export class CommonMixin extends Vue {
].includes(type)
}

/** Set store value of isLearBusiness flag by fetching business from Lear. */
async checkBusinessInLear (identifier: string): Promise<void> {
if (identifier) {
const fetchedBusiness = await BusinessServices.fetchBusiness(identifier)
if (fetchedBusiness) {
this.setIsLearBusiness(true)
} else {
this.setIsLearBusiness(false)
}
}
}

/** Scroll to given element Id */
scrollTo (id: string): void {
return document.getElementById(id)?.scrollIntoView()
Expand Down
3 changes: 1 addition & 2 deletions app/src/mixins/search-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Action, Getter } from 'vuex-class'
import { SessionStorageKeys } from 'sbc-common-components/src/util/constants'

// Interfaces / enums / etc.
import { BusinessSearchIF, ConversionTypesI, EntityI, RequestActionsI } from '@/interfaces'
import { ConversionTypesI, EntityI, RequestActionsI } from '@/interfaces'
import { ActionBindingIF } from '@/interfaces/store-interfaces'
import { AccountType, CompanyTypes, CorpTypeCd, EntityTypes, Location, NrRequestActionCodes,
NrRequestTypeCodes } from '@/enums'
Expand Down Expand Up @@ -35,7 +35,6 @@ export class SearchMixin extends Mixins(CommonMixin) {
@Getter getLocation!: Location
@Getter getOriginEntityTypeCd!: EntityTypes
@Getter getRequestActionCd!: NrRequestActionCodes
@Getter getSearchBusiness!: BusinessSearchIF
@Getter getSearchCompanyType!: CompanyTypes
@Getter getSearchJurisdiction!: any
@Getter getSearchRequest!: RequestActionsI
Expand Down
2 changes: 0 additions & 2 deletions app/src/plugins/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ const defaultFlagSet: LDFlagSet = {
'hardcoded_priority_wait_time': 0, // by default, use actual wait time
'hardcoded_regular_wait_time': 0, // by default, use actual wait time
'sentry-enable': false, // by default, no sentry logs
'supported-alteration-types': [],
'supported-amalgamation-entities': [],
'supported-continuation-in-entities': [],
'supported-incorporation-registration-entities': [],
'supported-name-change-entities': [],
'supported-restoration-entities': []
}

Expand Down
15 changes: 14 additions & 1 deletion app/src/services/business-services.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Axios from 'axios'
import { AddAxiosInterceptors } from '@/plugins'
import { BusinessRequest } from '@/interfaces'
import { NOT_FOUND } from 'http-status-codes'

const axios = AddAxiosInterceptors(Axios.create())

Expand All @@ -25,6 +26,18 @@ export default class BusinessServices {
*/
static async fetchBusiness (identifier: string): Promise<any> {
const url = `${BusinessServices.legalApiUrl}/businesses/${identifier}`
return axios.get(url).then(response => response.data?.business)
return axios.get(url)
.then(response => {
if (response.data?.business) {
return response.data?.business
}
console.log('fetchBusiness() error - invalid response =', response)
throw new Error('Invalid API response')
}).catch(error => {
if (error?.response?.status === NOT_FOUND) {
return null // Business not found (not an error)
}
throw error
})
}
}
4 changes: 4 additions & 0 deletions app/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@ export const setJurisdictionCd = ({ commit }, jurisdictionCd: string): void => {
commit('mutateJurisdictionCd', jurisdictionCd)
}

export const setIsLearBusiness = ({ commit }, isLearBusiness: boolean): void => {
commit('mutateIsLearBusiness', isLearBusiness)
}

export const setIsPersonsName = ({ commit }, isPersonsName: boolean): void => {
commit('mutateIsPersonsName', isPersonsName)
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/store/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ export const getIsPersonsName = (state: StateIF): boolean => {
return state.stateModel.newRequestModel.isPersonsName
}

export const getIsLearBusiness = (state: StateIF): boolean => {
return state.stateModel.newRequestModel.isLearBusiness
}

export const getDoNotAnalyzeEntities = (state: StateIF): EntityTypes[] => {
return state.stateModel.newRequestModel.doNotAnalyzeEntities
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export const mutateAffiliationErrorModalValue = (state: StateIF, affiliationErro
state.stateModel.newRequestModel.affiliationErrorModalValue = affiliationErrorModalValue
}

export const mutateIsLearBusiness = (state: StateIF, isLearBusiness: boolean) => {
state.stateModel.newRequestModel.isLearBusiness = isLearBusiness
}

export const mutateIsPersonsName = (state: StateIF, isPersonsName: boolean) => {
state.stateModel.newRequestModel.isPersonsName = isPersonsName
}
Expand Down
1 change: 1 addition & 0 deletions app/src/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const stateModel: StateModelIF = {
getNameReservationFailed: false,
helpMeChooseModalVisible: false,
affiliationErrorModalValue: NrAffiliationErrors.NONE, // initially hidden
isLearBusiness: false,
isPersonsName: false,
issueIndex: 0,
location: null,
Expand Down

0 comments on commit 9fec1a3

Please sign in to comment.