From f9a0f74dd12155c9465336be1114fc92fe4037f4 Mon Sep 17 00:00:00 2001 From: Yashwin Date: Tue, 1 Oct 2024 14:43:29 +0530 Subject: [PATCH 1/4] Implement industry mapping --- .../components/hooks/use-form-selectors.ts | 50 ++++++++++++++----- .../components/industries-selector.tsx | 20 +++++--- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts index 6f8883ba67b7..0f61e6b293b9 100644 --- a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts +++ b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts @@ -29,18 +29,30 @@ export function useFormSelectors() { }; const availableIndustries: Record< string, string > = { - agricultural_services: translate( 'Agricultural services' ), - business_services: translate( 'Business services' ), - clothing_shops: translate( 'Clothing shops' ), - contracted_services: translate( 'Contracted services' ), - government_services: translate( 'Government services' ), - miscellaneous_shops: translate( 'Miscellaneous shops' ), - professional_services_and_membership_organisations: translate( - 'Professional services and membership organisations' - ), - retail_outlet_services: translate( 'Retail outlet services' ), - transportation_services: translate( 'Transportation services' ), - utility_services: translate( 'Utility services' ), + technology_and_it_services: translate( 'Technology & IT Services' ), + e_commerce_and_retail: translate( 'E-commerce & Retail' ), + finance_and_insurance: translate( 'Finance & Insurance' ), + healthcare_and_medical: translate( 'Healthcare & Medical' ), + education_and_e_learning: translate( 'Education & E-Learning' ), + real_estate_and_property: translate( 'Real Estate & Property' ), + travel_and_hospitality: translate( 'Travel & Hospitality' ), + nonprofits_and_ngos: translate( 'Nonprofits & NGOs' ), + legal_and_professional_services: translate( 'Legal & Professional Services' ), + entertainment_and_media: translate( 'Entertainment & Media' ), + construction_and_engineering: translate( 'Construction & Engineering' ), + automotive_and_transportation: translate( 'Automotive & Transportation' ), + government_and_public_services: translate( 'Government & Public Services' ), + marketing_and_advertising: translate( 'Marketing & Advertising' ), + food_and_beverage: translate( 'Food & Beverage' ), + manufacturing_and_industry: translate( 'Manufacturing & Industry' ), + energy_and_utilities: translate( 'Energy & Utilities' ), + sports_and_recreation: translate( 'Sports & Recreation' ), + agriculture_and_farming: translate( 'Agriculture & Farming' ), + arts_and_culture: translate( 'Arts & Culture' ), + environmental_and_sustainability: translate( 'Environmental & Sustainability' ), + fashion_and_beauty: translate( 'Fashion & Beauty' ), + logistics_and_supply_chain: translate( 'Logistics & Supply Chain' ), + events_and_conferences: translate( 'Events & Conferences' ), }; const availableProducts: Record< string, string > = { @@ -58,11 +70,25 @@ export function useFormSelectors() { pressable: 'Pressable.com', }; + const oldIndustries: Record< string, string > = { + agricultural_services: 'agriculture_and_farming', + business_services: 'legal_and_professional_services', + clothing_shops: 'fashion_and_beauty', + contracted_services: 'legal_and_professional_services', + government_services: 'government_and_public_services', + miscellaneous_shops: 'e_commerce_and_retail', + professional_services_and_membership_organisations: 'legal_and_professional_services', + retail_outlet_services: 'e_commerce_and_retail', + transportation_services: 'automotive_and_transportation', + utility_services: 'energy_and_utilities', + }; + return { availableServices, availableLanguages, availableProducts, availableDirectories, availableIndustries, + oldIndustries, }; } diff --git a/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx b/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx index d398a6833d3e..491b9b211fcc 100644 --- a/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx +++ b/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx @@ -9,7 +9,7 @@ type Props = { }; const IndustriesSelector = ( { setIndustries, industries }: Props ) => { - const { availableIndustries } = useFormSelectors(); + const { availableIndustries, oldIndustries } = useFormSelectors(); // Get the reverse map of available industries const availableIndustriesByLabel = useMemo( @@ -31,12 +31,18 @@ const IndustriesSelector = ( { setIndustries, industries }: Props ) => { ); // Get the selected industries by label - const selectedIndustriesByLabel = industries.flatMap( ( slug ) => { - const key = slug as string; - const value = availableIndustries[ key ]; - return value ? [ value ] : []; - } ); - + const selectedIndustriesByLabel = Array.from( + new Set( + industries.flatMap( ( slug ) => { + const key = slug as string; + const value = + key in oldIndustries + ? availableIndustries[ oldIndustries[ key ] ] + : availableIndustries[ key ]; + return value ? [ value ] : []; + } ) + ) + ); return ( Date: Tue, 1 Oct 2024 14:55:43 +0530 Subject: [PATCH 2/4] sort industries --- .../partner-directory/components/hooks/use-form-selectors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts index 0f61e6b293b9..3e2eef43532d 100644 --- a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts +++ b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts @@ -88,7 +88,7 @@ export function useFormSelectors() { availableLanguages, availableProducts, availableDirectories, - availableIndustries, + availableIndustries: Object.fromEntries( Object.entries( availableIndustries ).sort() ), oldIndustries, }; } From 2de9f73edbf90443a0e7c099baf86969b5c6b480 Mon Sep 17 00:00:00 2001 From: Yashwin Date: Thu, 3 Oct 2024 11:12:57 +0530 Subject: [PATCH 3/4] Address PR comments t pus --- .../components/hooks/use-form-selectors.ts | 39 ++++++++++--------- .../components/industries-selector.tsx | 7 +--- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts index 3e2eef43532d..656a8970716b 100644 --- a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts +++ b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts @@ -28,31 +28,32 @@ export function useFormSelectors() { headless_wordpress_and_woo: translate( 'Headless WordPress & Woo' ), }; + // Always sort the industries alphabetically const availableIndustries: Record< string, string > = { - technology_and_it_services: translate( 'Technology & IT Services' ), + agriculture_and_farming: translate( 'Agriculture & Farming' ), + arts_and_culture: translate( 'Arts & Culture' ), + automotive_and_transportation: translate( 'Automotive & Transportation' ), + construction_and_engineering: translate( 'Construction & Engineering' ), + education_and_e_learning: translate( 'Education & E-Learning' ), e_commerce_and_retail: translate( 'E-commerce & Retail' ), + energy_and_utilities: translate( 'Energy & Utilities' ), + entertainment_and_media: translate( 'Entertainment & Media' ), + environmental_and_sustainability: translate( 'Environmental & Sustainability' ), + events_and_conferences: translate( 'Events & Conferences' ), + fashion_and_beauty: translate( 'Fashion & Beauty' ), finance_and_insurance: translate( 'Finance & Insurance' ), + food_and_beverage: translate( 'Food & Beverage' ), + government_and_public_services: translate( 'Government & Public Services' ), healthcare_and_medical: translate( 'Healthcare & Medical' ), - education_and_e_learning: translate( 'Education & E-Learning' ), - real_estate_and_property: translate( 'Real Estate & Property' ), - travel_and_hospitality: translate( 'Travel & Hospitality' ), - nonprofits_and_ngos: translate( 'Nonprofits & NGOs' ), legal_and_professional_services: translate( 'Legal & Professional Services' ), - entertainment_and_media: translate( 'Entertainment & Media' ), - construction_and_engineering: translate( 'Construction & Engineering' ), - automotive_and_transportation: translate( 'Automotive & Transportation' ), - government_and_public_services: translate( 'Government & Public Services' ), - marketing_and_advertising: translate( 'Marketing & Advertising' ), - food_and_beverage: translate( 'Food & Beverage' ), + logistics_and_supply_chain: translate( 'Logistics & Supply Chain' ), manufacturing_and_industry: translate( 'Manufacturing & Industry' ), - energy_and_utilities: translate( 'Energy & Utilities' ), + marketing_and_advertising: translate( 'Marketing & Advertising' ), + nonprofits_and_ngos: translate( 'Nonprofits & NGOs' ), + real_estate_and_property: translate( 'Real Estate & Property' ), sports_and_recreation: translate( 'Sports & Recreation' ), - agriculture_and_farming: translate( 'Agriculture & Farming' ), - arts_and_culture: translate( 'Arts & Culture' ), - environmental_and_sustainability: translate( 'Environmental & Sustainability' ), - fashion_and_beauty: translate( 'Fashion & Beauty' ), - logistics_and_supply_chain: translate( 'Logistics & Supply Chain' ), - events_and_conferences: translate( 'Events & Conferences' ), + technology_and_it_services: translate( 'Technology & IT Services' ), + travel_and_hospitality: translate( 'Travel & Hospitality' ), }; const availableProducts: Record< string, string > = { @@ -88,7 +89,7 @@ export function useFormSelectors() { availableLanguages, availableProducts, availableDirectories, - availableIndustries: Object.fromEntries( Object.entries( availableIndustries ).sort() ), + availableIndustries, oldIndustries, }; } diff --git a/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx b/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx index 491b9b211fcc..99dfb3fa3bba 100644 --- a/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx +++ b/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx @@ -30,15 +30,12 @@ const IndustriesSelector = ( { setIndustries, industries }: Props ) => { [ availableIndustriesByLabel, setIndustries ] ); - // Get the selected industries by label + // Get the selected industries by label, and remove any duplicates const selectedIndustriesByLabel = Array.from( new Set( industries.flatMap( ( slug ) => { const key = slug as string; - const value = - key in oldIndustries - ? availableIndustries[ oldIndustries[ key ] ] - : availableIndustries[ key ]; + const value = availableIndustries[ oldIndustries[ key ] ?? key ]; return value ? [ value ] : []; } ) ) From 00c444fbc281b9e9350a63cb6371f6f9a757bc18 Mon Sep 17 00:00:00 2001 From: Yashwin Date: Mon, 7 Oct 2024 09:24:05 +0530 Subject: [PATCH 4/4] revert the industry mapping --- .../components/hooks/use-form-selectors.ts | 14 -------------- .../components/industries-selector.tsx | 19 ++++++++----------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts index 656a8970716b..1300fc48c386 100644 --- a/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts +++ b/client/a8c-for-agencies/sections/partner-directory/components/hooks/use-form-selectors.ts @@ -71,25 +71,11 @@ export function useFormSelectors() { pressable: 'Pressable.com', }; - const oldIndustries: Record< string, string > = { - agricultural_services: 'agriculture_and_farming', - business_services: 'legal_and_professional_services', - clothing_shops: 'fashion_and_beauty', - contracted_services: 'legal_and_professional_services', - government_services: 'government_and_public_services', - miscellaneous_shops: 'e_commerce_and_retail', - professional_services_and_membership_organisations: 'legal_and_professional_services', - retail_outlet_services: 'e_commerce_and_retail', - transportation_services: 'automotive_and_transportation', - utility_services: 'energy_and_utilities', - }; - return { availableServices, availableLanguages, availableProducts, availableDirectories, availableIndustries, - oldIndustries, }; } diff --git a/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx b/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx index 99dfb3fa3bba..d398a6833d3e 100644 --- a/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx +++ b/client/a8c-for-agencies/sections/partner-directory/components/industries-selector.tsx @@ -9,7 +9,7 @@ type Props = { }; const IndustriesSelector = ( { setIndustries, industries }: Props ) => { - const { availableIndustries, oldIndustries } = useFormSelectors(); + const { availableIndustries } = useFormSelectors(); // Get the reverse map of available industries const availableIndustriesByLabel = useMemo( @@ -30,16 +30,13 @@ const IndustriesSelector = ( { setIndustries, industries }: Props ) => { [ availableIndustriesByLabel, setIndustries ] ); - // Get the selected industries by label, and remove any duplicates - const selectedIndustriesByLabel = Array.from( - new Set( - industries.flatMap( ( slug ) => { - const key = slug as string; - const value = availableIndustries[ oldIndustries[ key ] ?? key ]; - return value ? [ value ] : []; - } ) - ) - ); + // Get the selected industries by label + const selectedIndustriesByLabel = industries.flatMap( ( slug ) => { + const key = slug as string; + const value = availableIndustries[ key ]; + return value ? [ value ] : []; + } ); + return (