feat: more accurate industry tracking

This commit is contained in:
Shivam Mishra
2024-02-29 16:58:50 +05:30
parent 4f43446237
commit 17a111f324
3 changed files with 71 additions and 12 deletions
@@ -4,3 +4,37 @@ export const findMatchingOption = (value, options, defaultValue) => {
);
return match ? match.value || match : defaultValue;
};
export const findIndustryOptions = subIndustry => {
const industryMap = {
'Information Technology': [
'Semiconductors & Semiconductor Equipment',
'Internet Software & Services',
'IT Services',
'Software',
'Communications Equipment',
'Electronic Equipment, Instruments & Components',
'Technology Hardware, Storage & Peripherals',
],
Financials: [
'Banks',
'Diversified Financial Services',
'Capital Markets',
'Insurance',
],
'Health & Medicine': [
'Health Care Equipment & Supplies',
'Health Care Providers & Services',
'Biotechnology',
'Life Sciences Tools & Services',
'Pharmaceuticals',
],
Education: ['Education Services'],
};
const industry = Object.entries(industryMap).find(([, value]) =>
value.includes(subIndustry)
);
return industry ? industry[0] : 'Other';
};
@@ -1,4 +1,4 @@
import { findMatchingOption } from '../OnboardingHelper';
import { findMatchingOption, findIndustryOptions } from '../OnboardingHelper';
describe('findMatchingOption', () => {
const options = [{ value: 'option1' }, { value: 'option2' }];
@@ -13,3 +13,28 @@ describe('findMatchingOption', () => {
);
});
});
describe('findIndustryOptions', () => {
it('should return the correct industry for a given sub-industry', () => {
expect(
findIndustryOptions('Semiconductors & Semiconductor Equipment')
).toBe('Information Technology');
expect(findIndustryOptions('Banks')).toBe('Financials');
expect(findIndustryOptions('Health Care Equipment & Supplies')).toBe(
'Health & Medicine'
);
expect(findIndustryOptions('Education Services')).toBe('Education');
});
it('should return "Other" for a sub-industry not in the map', () => {
expect(findIndustryOptions('Non-existing Sub-industry')).toBe('Other');
});
it('should return "Other" for an empty string', () => {
expect(findIndustryOptions('')).toBe('Other');
});
it('should return "Other" for a null value', () => {
expect(findIndustryOptions(null)).toBe('Other');
});
});
@@ -94,7 +94,10 @@ import { ONBOARDING_STEP_NAMES } from 'dashboard/constants/globals';
import SubmitButton from 'dashboard/components/buttons/FormSubmitButton.vue';
import { timeZoneOptions } from 'dashboard/routes/dashboard/settings/inbox/helpers/businessHour.js';
import { getBrowserTimezone, getBrowserLocale } from 'v3/helpers/BrowserHelper';
import { findMatchingOption } from 'v3/helpers/OnboardingHelper';
import {
findMatchingOption,
findIndustryOptions,
} from 'v3/helpers/OnboardingHelper';
import alertMixin from 'shared/mixins/alertMixin';
import configMixin from 'shared/mixins/configMixin';
export default {
@@ -120,11 +123,12 @@ export default {
{ value: '1001+', label: 'Over 1000' },
],
industryOptions: [
{ value: 'information_technology', label: 'Information technology' },
{ value: 'finance', label: 'Finance' },
{ value: 'health_medicine', label: 'Health & Medicine' },
{ value: 'education', label: 'Education' },
{ value: 'other', label: 'Other' },
{ value: 'Information Technology', label: 'Information technology' },
{ value: 'Finance', label: 'Finance' },
{ value: 'Health & Medicine', label: 'Health & Medicine' },
{ value: 'Education', label: 'Education' },
{ value: 'E Commerce', label: 'E Commerce' },
{ value: 'Other', label: 'Other' },
],
};
},
@@ -227,11 +231,7 @@ export default {
this.accountAttributes;
this.companyName = companyName;
this.industry = findMatchingOption(
industry,
this.industryOptions,
'other'
);
this.industry = findIndustryOptions(industry);
this.companySize = companySize;
this.timezone = findMatchingOption(
timezone,