Skip to content

Commit

Permalink
refactore a function to remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jxio committed Apr 28, 2023
1 parent cc8157d commit 02e76d4
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions auth-web/src/store/modules/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ export default class BusinessModule extends VuexModule {
return OrgService.createNRAffiliation(this.currentOrganization.id, requestBody)
}

private addBusinessTypeforSP (filingBody: BusinessRequest, business: Business) {
// add in Business Type for SP
if (business.nameRequest.legalType === CorpTypes.SOLE_PROP) {
if (business.nameRequest.entityTypeCd === NrEntityType.FR) {
filingBody.filing.registration.businessType = CorpTypes.SOLE_PROP
} else if (business.nameRequest.entityTypeCd === NrEntityType.DBA) {
filingBody.filing.registration.businessType = NrEntityType.DBA
}
}
}

@Action({ rawError: true })
public async createNamedBusiness ({ filingType, business }: { filingType: FilingTypes, business: Business}) {
let filingBody: BusinessRequest = null
Expand All @@ -233,13 +244,7 @@ export default class BusinessModule extends VuexModule {
}

// add in Business Type for SP
if (business.nameRequest.legalType === CorpTypes.SOLE_PROP) {
if (business.nameRequest.entityTypeCd === NrEntityType.FR) {
filingBody.filing.registration.businessType = CorpTypes.SOLE_PROP
} else if (business.nameRequest.entityTypeCd === NrEntityType.DBA) {
filingBody.filing.registration.businessType = NrEntityType.DBA
}
}
this.addBusinessTypeforSP(filingBody, business)
break
}

Expand All @@ -263,13 +268,7 @@ export default class BusinessModule extends VuexModule {
}

// add in Business Type for SP
if (business.nameRequest.legalType === CorpTypes.SOLE_PROP) {
if (business.nameRequest.entityTypeCd === NrEntityType.FR) {
filingBody.filing.registration.businessType = CorpTypes.SOLE_PROP
} else if (business.nameRequest.entityTypeCd === NrEntityType.DBA) {
filingBody.filing.registration.businessType = NrEntityType.DBA
}
}
this.addBusinessTypeforSP(filingBody, business)
break
}
}
Expand Down

0 comments on commit 02e76d4

Please sign in to comment.