Skip to content

Commit 32644bc

Browse files
yashwincleacos
authored andcommitted
Implement industry mapping
1 parent b2f3dba commit 32644bc

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed

client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts

+38-12
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,30 @@ export function useFormSelectors() {
2929
};
3030

3131
const availableIndustries: Record< string, string > = {
32-
agricultural_services: translate( 'Agricultural services' ),
33-
business_services: translate( 'Business services' ),
34-
clothing_shops: translate( 'Clothing shops' ),
35-
contracted_services: translate( 'Contracted services' ),
36-
government_services: translate( 'Government services' ),
37-
miscellaneous_shops: translate( 'Miscellaneous shops' ),
38-
professional_services_and_membership_organisations: translate(
39-
'Professional services and membership organisations'
40-
),
41-
retail_outlet_services: translate( 'Retail outlet services' ),
42-
transportation_services: translate( 'Transportation services' ),
43-
utility_services: translate( 'Utility services' ),
32+
technology_and_it_services: translate( 'Technology & IT Services' ),
33+
e_commerce_and_retail: translate( 'E-commerce & Retail' ),
34+
finance_and_insurance: translate( 'Finance & Insurance' ),
35+
healthcare_and_medical: translate( 'Healthcare & Medical' ),
36+
education_and_e_learning: translate( 'Education & E-Learning' ),
37+
real_estate_and_property: translate( 'Real Estate & Property' ),
38+
travel_and_hospitality: translate( 'Travel & Hospitality' ),
39+
nonprofits_and_ngos: translate( 'Nonprofits & NGOs' ),
40+
legal_and_professional_services: translate( 'Legal & Professional Services' ),
41+
entertainment_and_media: translate( 'Entertainment & Media' ),
42+
construction_and_engineering: translate( 'Construction & Engineering' ),
43+
automotive_and_transportation: translate( 'Automotive & Transportation' ),
44+
government_and_public_services: translate( 'Government & Public Services' ),
45+
marketing_and_advertising: translate( 'Marketing & Advertising' ),
46+
food_and_beverage: translate( 'Food & Beverage' ),
47+
manufacturing_and_industry: translate( 'Manufacturing & Industry' ),
48+
energy_and_utilities: translate( 'Energy & Utilities' ),
49+
sports_and_recreation: translate( 'Sports & Recreation' ),
50+
agriculture_and_farming: translate( 'Agriculture & Farming' ),
51+
arts_and_culture: translate( 'Arts & Culture' ),
52+
environmental_and_sustainability: translate( 'Environmental & Sustainability' ),
53+
fashion_and_beauty: translate( 'Fashion & Beauty' ),
54+
logistics_and_supply_chain: translate( 'Logistics & Supply Chain' ),
55+
events_and_conferences: translate( 'Events & Conferences' ),
4456
};
4557

4658
const availableProducts: Record< string, string > = {
@@ -58,11 +70,25 @@ export function useFormSelectors() {
5870
pressable: 'Pressable.com',
5971
};
6072

73+
const oldIndustries: Record< string, string > = {
74+
agricultural_services: 'agriculture_and_farming',
75+
business_services: 'legal_and_professional_services',
76+
clothing_shops: 'fashion_and_beauty',
77+
contracted_services: 'legal_and_professional_services',
78+
government_services: 'government_and_public_services',
79+
miscellaneous_shops: 'e_commerce_and_retail',
80+
professional_services_and_membership_organisations: 'legal_and_professional_services',
81+
retail_outlet_services: 'e_commerce_and_retail',
82+
transportation_services: 'automotive_and_transportation',
83+
utility_services: 'energy_and_utilities',
84+
};
85+
6186
return {
6287
availableServices,
6388
availableLanguages,
6489
availableProducts,
6590
availableDirectories,
6691
availableIndustries,
92+
oldIndustries,
6793
};
6894
}

client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx

+13-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Props = {
99
};
1010

1111
const IndustriesSelector = ( { setIndustries, industries }: Props ) => {
12-
const { availableIndustries } = useFormSelectors();
12+
const { availableIndustries, oldIndustries } = useFormSelectors();
1313

1414
// Get the reverse map of available industries
1515
const availableIndustriesByLabel = useMemo(
@@ -31,12 +31,18 @@ const IndustriesSelector = ( { setIndustries, industries }: Props ) => {
3131
);
3232

3333
// Get the selected industries by label
34-
const selectedIndustriesByLabel = industries.flatMap( ( slug ) => {
35-
const key = slug as string;
36-
const value = availableIndustries[ key ];
37-
return value ? [ value ] : [];
38-
} );
39-
34+
const selectedIndustriesByLabel = Array.from(
35+
new Set(
36+
industries.flatMap( ( slug ) => {
37+
const key = slug as string;
38+
const value =
39+
key in oldIndustries
40+
? availableIndustries[ oldIndustries[ key ] ]
41+
: availableIndustries[ key ];
42+
return value ? [ value ] : [];
43+
} )
44+
)
45+
);
4046
return (
4147
<FormTokenFieldWrapper
4248
onChange={ handleSetIndustries }

0 commit comments

Comments
 (0)