@mychoice/mychoice-sdk-store 2.1.82 → 2.1.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
- import { SelectOptionInterface } from '@mychoice/mychoice-sdk-components';
1
+ import { SelectOptionInterface, SelectOptionGroupInterface } from '@mychoice/mychoice-sdk-components';
2
2
  import { DataHandlerRequestState } from '../shared';
3
3
  export type UseHandlerVehicleMakeInterface = DataHandlerRequestState & {
4
4
  getVehicleMake: (year: string) => void;
5
5
  vehicleMakeList: SelectOptionInterface[];
6
+ vehicleMakeGroupList: SelectOptionGroupInterface[];
6
7
  };
7
8
  export type UseHandlerVehicleModelInterface = DataHandlerRequestState & {
8
9
  getVehicleModel: (year: string, make: string) => void;
package/dist/cjs/index.js CHANGED
@@ -4677,10 +4677,23 @@ const useHandlerPostal = (insuranceType) => {
4677
4677
  };
4678
4678
  };
4679
4679
 
4680
+ const POPULAR_MAKES = [
4681
+ 'CHEVROLET',
4682
+ 'DODGE/RAM',
4683
+ 'FORD',
4684
+ 'HONDA',
4685
+ 'HYUNDAI',
4686
+ 'KIA',
4687
+ 'MAZDA',
4688
+ 'NISSAN',
4689
+ 'TOYOTA',
4690
+ 'VOLKSWAGEN',
4691
+ ];
4680
4692
  const useHandlerCarMake = () => {
4681
4693
  const [requestState, setRequestState] = react.useReducer(dataHandlerReducer, { ...initialHandlerRequestState });
4682
4694
  const { cancelToken } = useCancelToken();
4683
4695
  const [vehicleMakeList, setVehicleMakeList] = react.useState([]);
4696
+ const [vehicleMakeGroupList, setVehicleMakeGroupList] = react.useState([]);
4684
4697
  const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
4685
4698
  const getVehicleMake = async (year) => {
4686
4699
  setRequestState({ type: DataHandlerActionTypes.SetLoading, payload: true });
@@ -4692,7 +4705,20 @@ const useHandlerCarMake = () => {
4692
4705
  withoutToken: true,
4693
4706
  cancelToken,
4694
4707
  });
4695
- setVehicleMakeList(response.data.map(({ make }) => ({ name: make, value: make })));
4708
+ const allMakes = response.data.map(({ make }) => ({ name: make, value: make }));
4709
+ const popularMakes = allMakes.filter((make) => POPULAR_MAKES.includes(make.value));
4710
+ const otherMakes = allMakes.filter((make) => !POPULAR_MAKES.includes(make.value));
4711
+ setVehicleMakeList([]);
4712
+ setVehicleMakeGroupList([
4713
+ {
4714
+ label: 'Popular Makes',
4715
+ options: popularMakes,
4716
+ },
4717
+ {
4718
+ label: 'All Makes',
4719
+ options: otherMakes,
4720
+ },
4721
+ ]);
4696
4722
  setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
4697
4723
  }
4698
4724
  catch (error) {
@@ -4712,6 +4738,7 @@ const useHandlerCarMake = () => {
4712
4738
  isFirstRequest,
4713
4739
  responseError,
4714
4740
  vehicleMakeList,
4741
+ vehicleMakeGroupList,
4715
4742
  };
4716
4743
  };
4717
4744
  const useHandlerCarModel = () => {