@tap-payments/os-micro-frontend-shared 0.1.254-test.4 → 0.1.254-test.5

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.
@@ -19,12 +19,10 @@ const DropdownArrowIcon = ({ isLoading, isSingleMerchant, isOpen }) => {
19
19
  return null;
20
20
  };
21
21
  function MerchantsDropdown({ brands, isLoading = true, label, sx, selectedValue, isDisabled, isFetchingNextPage, renderBrandLogo, onValueChange, }) {
22
- // const { brands: brandsList, getBrandDetailsById, isLoading, isFetchingNextPage } = useBrands()
23
22
  var _a;
24
23
  const { anchorElement, isOpen, openMenu, closeMenu } = useDropdownMenu();
25
24
  const controllerRef = useRef(null);
26
25
  useDefaultMerchantSelection(brands, selectedValue, onValueChange);
27
- // const { displayName } = useSelectedMerchantDetails(selectedValue, getBrandDetailsById)
28
26
  const isSingleMerchant = useMemo(() => getIsSingleMerchant(brands), [brands]);
29
27
  const shouldDisableInteraction = isSingleMerchant || isDisabled || isLoading;
30
28
  const handleContainerClick = useCallback((event) => {
@@ -1,5 +1,5 @@
1
1
  import { MouseEvent } from 'react';
2
- import { Brand, Entity, Merchant, MerchantInfo } from '../../types/index.js';
2
+ import { Brand, MerchantInfo } from '../../types/index.js';
3
3
  /**
4
4
  * Custom hook to handle dropdown menu state
5
5
  */
@@ -13,15 +13,6 @@ export declare const useDropdownMenu: () => {
13
13
  * Custom hook to handle default merchant selection
14
14
  */
15
15
  export declare const useDefaultMerchantSelection: (brandsList: Brand[], selectedValue: MerchantInfo | undefined, onValueChange: (merchant: Required<MerchantInfo>) => void) => void;
16
- /**
17
- * Custom hook to get selected merchant details
18
- */
19
- export declare const useSelectedMerchantDetails: (selectedValue: MerchantInfo | undefined, getBrandDetailsById: (id: string) => Brand | undefined) => {
20
- selectedBrand: Brand | undefined;
21
- selectedEntity: (import("../../types/index.js").EntityDetails & Entity) | undefined;
22
- selectedMerchant: Merchant | undefined;
23
- displayName: string;
24
- };
25
16
  /**
26
17
  * Check if only one merchant exists across all brands
27
18
  */
@@ -1,4 +1,4 @@
1
- import { useState, useMemo, useEffect, useCallback } from 'react';
1
+ import { useState, useEffect, useCallback } from 'react';
2
2
  /**
3
3
  * Custom hook to handle dropdown menu state
4
4
  */
@@ -45,21 +45,6 @@ export const useDefaultMerchantSelection = (brandsList, selectedValue, onValueCh
45
45
  });
46
46
  }, [brandsList, selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.merchantId, onValueChange]);
47
47
  };
48
- /**
49
- * Custom hook to get selected merchant details
50
- */
51
- export const useSelectedMerchantDetails = (selectedValue, getBrandDetailsById) => {
52
- const selectedBrand = useMemo(() => { var _a; return getBrandDetailsById((_a = selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.brandId) !== null && _a !== void 0 ? _a : ''); }, [getBrandDetailsById, selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.brandId]);
53
- const selectedEntity = useMemo(() => selectedBrand === null || selectedBrand === void 0 ? void 0 : selectedBrand.entities.find((entity) => entity.id === (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.entityId)), [selectedBrand, selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.entityId]);
54
- const selectedMerchant = useMemo(() => { var _a; return (_a = selectedEntity === null || selectedEntity === void 0 ? void 0 : selectedEntity.merchants) === null || _a === void 0 ? void 0 : _a.find((merchant) => merchant.id === (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.merchantId)); }, [selectedEntity, selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.merchantId]);
55
- const displayName = useMemo(() => { var _a, _b; return (_b = (_a = selectedMerchant === null || selectedMerchant === void 0 ? void 0 : selectedMerchant.display_name) !== null && _a !== void 0 ? _a : selectedMerchant === null || selectedMerchant === void 0 ? void 0 : selectedMerchant.legacy_id) !== null && _b !== void 0 ? _b : 'Select'; }, [selectedMerchant]);
56
- return {
57
- selectedBrand,
58
- selectedEntity,
59
- selectedMerchant,
60
- displayName,
61
- };
62
- };
63
48
  /**
64
49
  * Check if only one merchant exists across all brands
65
50
  */
@@ -1,3 +1 @@
1
1
  export { default as MerchantsDropdown } from './MerchantsDropdown';
2
- export * from './hooks';
3
- export * from './type';
@@ -1,3 +1 @@
1
1
  export { default as MerchantsDropdown } from './MerchantsDropdown';
2
- export * from './hooks';
3
- export * from './type';
@@ -12,3 +12,4 @@ export * from './useCountdown';
12
12
  export * from './useAppsInfo';
13
13
  export * from './useAppEventPublisher';
14
14
  export * from './useAppEventListener';
15
+ export * from './useSelectedMerchantDetails';
@@ -12,3 +12,4 @@ export * from './useCountdown';
12
12
  export * from './useAppsInfo';
13
13
  export * from './useAppEventPublisher';
14
14
  export * from './useAppEventListener';
15
+ export * from './useSelectedMerchantDetails';
@@ -0,0 +1,10 @@
1
+ import { Brand, Entity, Merchant, MerchantInfo } from '../types/index.js';
2
+ /**
3
+ * Custom hook to get selected merchant details
4
+ */
5
+ export declare const useSelectedMerchantDetails: (selectedValue: MerchantInfo | undefined, selectedBrand?: Brand) => {
6
+ selectedBrand: Brand | undefined;
7
+ selectedEntity: (import("../types/index.js").EntityDetails & Entity) | undefined;
8
+ selectedMerchant: Merchant | undefined;
9
+ displayName: string;
10
+ };
@@ -0,0 +1,15 @@
1
+ import { useMemo } from 'react';
2
+ /**
3
+ * Custom hook to get selected merchant details
4
+ */
5
+ export const useSelectedMerchantDetails = (selectedValue, selectedBrand) => {
6
+ const selectedEntity = useMemo(() => selectedBrand === null || selectedBrand === void 0 ? void 0 : selectedBrand.entities.find((entity) => entity.id === (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.entityId)), [selectedBrand, selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.entityId]);
7
+ const selectedMerchant = useMemo(() => { var _a; return (_a = selectedEntity === null || selectedEntity === void 0 ? void 0 : selectedEntity.merchants) === null || _a === void 0 ? void 0 : _a.find((merchant) => merchant.id === (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.merchantId)); }, [selectedEntity, selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.merchantId]);
8
+ const displayName = useMemo(() => { var _a, _b; return (_b = (_a = selectedMerchant === null || selectedMerchant === void 0 ? void 0 : selectedMerchant.display_name) !== null && _a !== void 0 ? _a : selectedMerchant === null || selectedMerchant === void 0 ? void 0 : selectedMerchant.legacy_id) !== null && _b !== void 0 ? _b : 'Select'; }, [selectedMerchant]);
9
+ return {
10
+ selectedBrand,
11
+ selectedEntity,
12
+ selectedMerchant,
13
+ displayName,
14
+ };
15
+ };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.254-test.4",
5
- "testVersion": 4,
4
+ "version": "0.1.254-test.5",
5
+ "testVersion": 5,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",