Skip to content

Commit

Permalink
fixed corp type filtering (#177)
Browse files Browse the repository at this point in the history
Signed-off-by: Kial Jinnah <kialjinnah@gmail.com>

Signed-off-by: Kial Jinnah <kialjinnah@gmail.com>
Co-authored-by: Kial Jinnah <kialjinnah@gmail.com>
  • Loading branch information
Kial and kialj876 authored Oct 27, 2022
1 parent 24bebf2 commit 5b0cde1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
1 change: 0 additions & 1 deletion search-ui/src/enums/corp-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export enum CorpTypeCd {
BENEFIT_COMPANY = 'BEN',
CONTINUE_IN = 'C',
BC_CCC = 'CC',
CCC_CONTINUE_IN = 'CCC',
CEMETARY = 'CEM',
COOP = 'CP',
BC_CORPORATION = 'CR', // SPECIAL NAMEREQUEST-ONLY ENTITY TYPE
Expand Down
20 changes: 14 additions & 6 deletions search-ui/src/requests/search-api/search-api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ export const addSearchBusFilters = (filters: SearchFilterI) => {
if (filters?.name) filterParams.query += `::name:${filters.name}`
// categories
if (filters?.legalType) {
// group society legal types
const societyTypes = [CorpTypeCd.CONT_IN_SOCIETY, CorpTypeCd.SOCIETY, CorpTypeCd.SOCIETY_BRANCH]
if (societyTypes.includes(filters.legalType as CorpTypeCd)) {
// query by all society corp types
filters.legalType = societyTypes.join(',') as CorpTypeCd
} else if (filters.legalType === 'Other' as CorpTypeCd) {
// group specific corp types together
if (filters.legalType === 'Other' as CorpTypeCd) {
// query by all 'other' corp types
filters.legalType = OtherCorpTypes.join(',') as CorpTypeCd
} else {
const bcLimitedTypes = [CorpTypeCd.CONTINUE_IN, CorpTypeCd.BC_COMPANY]
const ulcTypes = [CorpTypeCd.ULC_CONTINUE_IN, CorpTypeCd.BC_ULC_COMPANY]
const societyTypes = [CorpTypeCd.CONT_IN_SOCIETY, CorpTypeCd.SOCIETY, CorpTypeCd.SOCIETY_BRANCH]
const corp_grps = [bcLimitedTypes, ulcTypes, societyTypes]
for (const i in corp_grps) {
if (corp_grps[i].includes(filters.legalType as CorpTypeCd)) {
// query by all society corp types
filters.legalType = corp_grps[i].join(',') as CorpTypeCd
break
}
}
}
filterParams.categories += `legalType:${filters.legalType}`
}
Expand Down
42 changes: 18 additions & 24 deletions search-ui/src/resources/corp-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ import { CorpClass, CorpTypeCd } from '@/enums'
corpClass: CorpClass.XPRO,
shortDesc: 'EXTRA PRO',
fullDesc: 'Extraprovincial Company'
}, {
corpTypeCd: CorpTypeCd.BC_COMPANY,
colinInd: true,
corpClass: CorpClass.BC,
shortDesc: 'BC COMPANY',
fullDesc: 'BC Limited Company',
numberedDesc: 'Numbered Limited Company'
}, {
corpTypeCd: CorpTypeCd.BENEFIT_COMPANY,
colinInd: true,
corpClass: CorpClass.BC,
shortDesc: 'BENEFIT COMPANY',
fullDesc: 'BC Benefit Company',
numberedDesc: 'Numbered Benefit Company'
}, {
corpTypeCd: CorpTypeCd.BC_COMPANY,
colinInd: true,
corpClass: CorpClass.BC,
shortDesc: 'BC COMPANY',
fullDesc: 'BC Limited Company',
numberedDesc: 'Numbered Limited Company'
}, {
corpTypeCd: CorpTypeCd.CONTINUE_IN,
colinInd: true,
Expand All @@ -42,12 +42,6 @@ import { CorpClass, CorpTypeCd } from '@/enums'
corpClass: CorpClass.BC,
shortDesc: 'BC CCC',
fullDesc: 'BC Community Contribution Company'
}, {
corpTypeCd: CorpTypeCd.CCC_CONTINUE_IN,
colinInd: true,
corpClass: CorpClass.BC,
shortDesc: 'CCC CONTINUE IN',
fullDesc: 'BC Community Contribution Company'
}, {
corpTypeCd: CorpTypeCd.CEMETARY,
colinInd: false,
Expand All @@ -70,11 +64,12 @@ import { CorpClass, CorpTypeCd } from '@/enums'
fullDesc: 'BC Company', // BC Company - Incorporation/Amalgamation
numberedDesc: 'Numbered Company'
}, {
corpTypeCd: CorpTypeCd.CONT_IN_SOCIETY,
corpTypeCd: CorpTypeCd.BC_ULC_COMPANY,
colinInd: true,
corpClass: CorpClass.SOC,
shortDesc: 'CONT IN SOCIETY',
fullDesc: 'BC Society'
corpClass: CorpClass.BC,
shortDesc: 'BC ULC COMPANY',
fullDesc: 'BC Unlimited Liability Company',
numberedDesc: 'Numbered Unlimited Liability Company'
}, {
corpTypeCd: CorpTypeCd.ULC_CONTINUE_IN,
colinInd: true,
Expand Down Expand Up @@ -219,6 +214,12 @@ import { CorpClass, CorpTypeCd } from '@/enums'
corpClass: CorpClass.OT,
shortDesc: 'SOCIETY BRANCH',
fullDesc: 'BC Society'
}, {
corpTypeCd: CorpTypeCd.CONT_IN_SOCIETY,
colinInd: true,
corpClass: CorpClass.SOC,
shortDesc: 'CONT IN SOCIETY',
fullDesc: 'BC Society'
}, {
corpTypeCd: CorpTypeCd.SOLE_PROP,
colinInd: true,
Expand All @@ -237,13 +238,6 @@ import { CorpClass, CorpTypeCd } from '@/enums'
corpClass: CorpClass.OT,
shortDesc: 'TRAMWAYS',
fullDesc: 'Tramways'
}, {
corpTypeCd: CorpTypeCd.BC_ULC_COMPANY,
colinInd: true,
corpClass: CorpClass.BC,
shortDesc: 'BC ULC COMPANY',
fullDesc: 'BC Unlimited Liability Company',
numberedDesc: 'Numbered Unlimited Liability Company'
}, {
corpTypeCd: CorpTypeCd.ULC_CO_1860,
colinInd: true,
Expand Down

0 comments on commit 5b0cde1

Please sign in to comment.