@tap-payments/os-micro-frontend-shared 0.1.329 → 0.1.330

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.
@@ -0,0 +1,5 @@
1
+ interface PaymentIconProps {
2
+ type: string;
3
+ }
4
+ export declare function PaymentIcon({ type }: PaymentIconProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Box from '@mui/material/Box';
3
+ import { getPaymentMethodsIcon } from '../../constants/index.js';
4
+ import { PaymentChip } from './style';
5
+ export function PaymentIcon({ type }) {
6
+ return (_jsx(PaymentChip, { children: _jsx(Box, { component: "img", src: getPaymentMethodsIcon(type), sx: { width: 18, height: 12, objectFit: 'contain' }, onError: (e) => {
7
+ e.currentTarget.src = getPaymentMethodsIcon('card');
8
+ } }) }));
9
+ }
@@ -14,6 +14,7 @@ import { useState, useCallback, useMemo } from 'react';
14
14
  import { Menu } from '../index.js';
15
15
  import { rightArrow } from '../../constants/index.js';
16
16
  import { MenuItemStyled } from './style';
17
+ import { PaymentIcon } from './PaymentIcon';
17
18
  export default function PaymentMethod({ icon, name, options = [], filters, setFilters }) {
18
19
  var _a;
19
20
  const [anchorEl, setAnchorEl] = useState(null);
@@ -50,5 +51,5 @@ export default function PaymentMethod({ icon, name, options = [], filters, setFi
50
51
  setFilters(Object.assign(Object.assign({}, filters), { payment_methods: [...(paymentMethods !== null && paymentMethods !== void 0 ? paymentMethods : []), selectedPaymentMethod] }));
51
52
  }
52
53
  };
53
- return (_jsxs(MenuItemStyled, Object.assign({ isSelected: isSelected, isIndeterminate: isIndeterminate, onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick }, { children: [_jsx("img", { src: icon, alt: name }), _jsx("span", Object.assign({ className: "label" }, { children: name })), _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(Menu, Object.assign({ open: Boolean(anchorEl), anchorEl: anchorEl, placement: "right-end" }, { children: options === null || options === void 0 ? void 0 : options.map((option) => (_jsx(MenuItemStyled, Object.assign({ isSelected: isSelectedPaymentMethod(option.type), onClick: (e) => onClickPaymentMethod(e, option.type) }, { children: _jsx("img", { src: option.icon, alt: option === null || option === void 0 ? void 0 : option.name, style: { height: 24, width: 36, objectFit: 'contain' } }) }), option.type))) }))] })));
54
+ return (_jsxs(MenuItemStyled, Object.assign({ isSelected: isSelected, isIndeterminate: isIndeterminate, onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick }, { children: [_jsx("img", { src: icon, alt: name }), _jsx("span", Object.assign({ className: "label" }, { children: name })), _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(Menu, Object.assign({ open: Boolean(anchorEl), anchorEl: anchorEl, placement: "right-end" }, { children: options === null || options === void 0 ? void 0 : options.map((option) => (_jsx(MenuItemStyled, Object.assign({ isSelected: isSelectedPaymentMethod(option.type), onClick: (e) => onClickPaymentMethod(e, option.type) }, { children: _jsx(PaymentIcon, { type: option.type }) }), option.type))) }))] })));
54
55
  }
@@ -14,6 +14,7 @@ import { useCallback, useMemo, useState } from 'react';
14
14
  import { Menu } from '../index.js';
15
15
  import { rightArrow } from '../../constants/index.js';
16
16
  import { MenuItemStyled } from './style';
17
+ import { PaymentIcon } from './PaymentIcon';
17
18
  export default function PaymentSchemes({ paymentSchemesSource, filters, setFilters }) {
18
19
  var _a, _b, _c, _d;
19
20
  const [anchorEl, setAnchorEl] = useState(null);
@@ -49,5 +50,5 @@ export default function PaymentSchemes({ paymentSchemesSource, filters, setFilte
49
50
  setFilters(Object.assign(Object.assign({}, filters), { payment_scheme: [...((_b = filters === null || filters === void 0 ? void 0 : filters.payment_scheme) !== null && _b !== void 0 ? _b : []), selectedPaymentScheme] }));
50
51
  }
51
52
  };
52
- return (_jsxs(MenuItemStyled, Object.assign({ isSelected: isSelected, isIndeterminate: isIndeterminate, onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick, sx: Object.assign({}, (isDisabled && { opacity: 0.5, pointerEvents: 'none' })) }, { children: [_jsx("span", Object.assign({ className: "label" }, { children: paymentSchemesSource === null || paymentSchemesSource === void 0 ? void 0 : paymentSchemesSource.name })), _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(Menu, Object.assign({ open: Boolean(anchorEl), anchorEl: anchorEl, placement: "right-start" }, { children: (_d = paymentSchemesSource === null || paymentSchemesSource === void 0 ? void 0 : paymentSchemesSource.options) === null || _d === void 0 ? void 0 : _d.map((scheme) => (_jsx(MenuItemStyled, Object.assign({ isSelected: isSelectedPaymentScheme(scheme.type), onClick: (e) => onClickPaymentScheme(e, scheme.type) }, { children: _jsx("img", { src: scheme.icon, alt: scheme === null || scheme === void 0 ? void 0 : scheme.name, style: { height: 24 } }) }), scheme.type))) }))] })));
53
+ return (_jsxs(MenuItemStyled, Object.assign({ isSelected: isSelected, isIndeterminate: isIndeterminate, onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick, sx: Object.assign({}, (isDisabled && { opacity: 0.5, pointerEvents: 'none' })) }, { children: [_jsx("span", Object.assign({ className: "label" }, { children: paymentSchemesSource === null || paymentSchemesSource === void 0 ? void 0 : paymentSchemesSource.name })), _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(Menu, Object.assign({ open: Boolean(anchorEl), anchorEl: anchorEl, placement: "right-start" }, { children: (_d = paymentSchemesSource === null || paymentSchemesSource === void 0 ? void 0 : paymentSchemesSource.options) === null || _d === void 0 ? void 0 : _d.map((scheme) => (_jsx(MenuItemStyled, Object.assign({ isSelected: isSelectedPaymentScheme(scheme.type), onClick: (e) => onClickPaymentScheme(e, scheme.type) }, { children: _jsx(PaymentIcon, { type: scheme.type }) }), scheme.type))) }))] })));
53
54
  }
@@ -1 +1,5 @@
1
+ /// <reference types="react" />
1
2
  export declare const MenuItemStyled: import("@emotion/styled").StyledComponent<import("../MenuItem/MenuItem").MenuItemProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
3
+ export declare const PaymentChip: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
4
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
5
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
@@ -1,4 +1,5 @@
1
1
  import { styled } from '@mui/material/styles';
2
+ import Box from '@mui/material/Box';
2
3
  import { MenuItem } from '../index.js';
3
4
  export const MenuItemStyled = styled(MenuItem)(({ theme }) => ({
4
5
  height: 40,
@@ -10,3 +11,12 @@ export const MenuItemStyled = styled(MenuItem)(({ theme }) => ({
10
11
  flexGrow: 1,
11
12
  },
12
13
  }));
14
+ export const PaymentChip = styled(Box)(({ theme }) => ({
15
+ width: 36,
16
+ height: 24,
17
+ border: `1px solid ${theme.palette.divider}`,
18
+ display: 'flex',
19
+ alignItems: 'center',
20
+ justifyContent: 'center',
21
+ borderRadius: '12px',
22
+ }));
@@ -8,8 +8,14 @@ export declare enum SEGMENT_CODE {
8
8
  BUSINESS = "BUSINESS",
9
9
  PLATFORM = "PLATFORM",
10
10
  DEVELOPMENT = "DEVELOPMENT",
11
+ PSP = "PSP",
11
12
  PAYMENT_TECHNOLOGY = "PAYMENT_TECHNOLOGY",
12
13
  PAYMENT_FACILITATOR = "PAYMENT_FACILITATOR",
13
14
  PAYMENT_ACQUIRER = "PAYMENT_ACQUIRER",
14
- PAYMENT_GATEWAY = "PAYMENT_GATEWAY"
15
+ PAYMENT_GATEWAY = "PAYMENT_GATEWAY",
16
+ BILLING_PLATFORM = "BILLING_PLATFORM",
17
+ COMMERCE_PLATFORM = "COMMERCE_PLATFORM",
18
+ DEVELOPMENT_HOUSE = "DEVELOPMENT_HOUSE",
19
+ PAYMENT_GATEWAY_PROVIDER = "PAYMENT_GATEWAY_PROVIDER",
20
+ RETAIL_PLATFORM = "RETAIL_PLATFORM"
15
21
  }
@@ -3,8 +3,14 @@ export var SEGMENT_CODE;
3
3
  SEGMENT_CODE["BUSINESS"] = "BUSINESS";
4
4
  SEGMENT_CODE["PLATFORM"] = "PLATFORM";
5
5
  SEGMENT_CODE["DEVELOPMENT"] = "DEVELOPMENT";
6
+ SEGMENT_CODE["PSP"] = "PSP";
6
7
  SEGMENT_CODE["PAYMENT_TECHNOLOGY"] = "PAYMENT_TECHNOLOGY";
7
8
  SEGMENT_CODE["PAYMENT_FACILITATOR"] = "PAYMENT_FACILITATOR";
8
9
  SEGMENT_CODE["PAYMENT_ACQUIRER"] = "PAYMENT_ACQUIRER";
9
10
  SEGMENT_CODE["PAYMENT_GATEWAY"] = "PAYMENT_GATEWAY";
11
+ SEGMENT_CODE["BILLING_PLATFORM"] = "BILLING_PLATFORM";
12
+ SEGMENT_CODE["COMMERCE_PLATFORM"] = "COMMERCE_PLATFORM";
13
+ SEGMENT_CODE["DEVELOPMENT_HOUSE"] = "DEVELOPMENT_HOUSE";
14
+ SEGMENT_CODE["PAYMENT_GATEWAY_PROVIDER"] = "PAYMENT_GATEWAY_PROVIDER";
15
+ SEGMENT_CODE["RETAIL_PLATFORM"] = "RETAIL_PLATFORM";
10
16
  })(SEGMENT_CODE || (SEGMENT_CODE = {}));
@@ -16,7 +16,6 @@ export declare function transformPaymentMethodsData(data?: PaymentMethod[]): {
16
16
  options: {
17
17
  name: string | undefined;
18
18
  type: string;
19
- icon: string;
20
19
  }[];
21
20
  }[] | undefined;
22
21
  };
@@ -26,7 +25,6 @@ export declare function transformPaymentSchemesData(data?: Source[]): {
26
25
  options: {
27
26
  name: string | undefined;
28
27
  type: string;
29
- icon: string;
30
28
  }[];
31
29
  };
32
30
  export {};
@@ -1,20 +1,19 @@
1
1
  import capitalize from 'lodash/capitalize';
2
- import { lightUrl, PAYMENT_TYPES_ICONS } from '../constants/index.js';
2
+ import { PAYMENT_TYPES_ICONS } from '../constants/index.js';
3
3
  import { getNameText } from './language';
4
4
  export function transformPaymentMethodsData(data) {
5
5
  return {
6
6
  name: 'Payment Methods',
7
7
  type: 'payment_methods',
8
8
  options: data === null || data === void 0 ? void 0 : data.map((category) => {
9
- var _a;
9
+ var _a, _b;
10
10
  return {
11
11
  name: capitalize(getNameText(category === null || category === void 0 ? void 0 : category.name)),
12
12
  type: category === null || category === void 0 ? void 0 : category.code,
13
- icon: PAYMENT_TYPES_ICONS[category.code],
14
- options: (_a = category.payment_methods) === null || _a === void 0 ? void 0 : _a.map((method) => ({
13
+ icon: (_a = PAYMENT_TYPES_ICONS[category.code]) !== null && _a !== void 0 ? _a : PAYMENT_TYPES_ICONS.CARD,
14
+ options: (_b = category.payment_methods) === null || _b === void 0 ? void 0 : _b.map((method) => ({
15
15
  name: getNameText(method.name),
16
16
  type: method.code,
17
- icon: `${lightUrl}/payment-method/${method.code}.svg`,
18
17
  })),
19
18
  };
20
19
  }),
@@ -30,7 +29,6 @@ export function transformPaymentSchemesData(data = []) {
30
29
  return {
31
30
  name: getNameText(scheme === null || scheme === void 0 ? void 0 : scheme.name),
32
31
  type: scheme === null || scheme === void 0 ? void 0 : scheme.code,
33
- icon: `${lightUrl}/payment-method/${scheme.code}.svg`,
34
32
  };
35
33
  }),
36
34
  };
@@ -1,2 +1,66 @@
1
1
  import { Segment, SegmentData } from '../types/index.js';
2
2
  export declare const getSegmentData: (segments: Segment[], activeSegmentId: string, activeSegments: Segment[]) => SegmentData;
3
+ export declare const getBusinessSegmentConfig: (merchantsIds: string[]) => {
4
+ business?: undefined;
5
+ } | {
6
+ business: {
7
+ merchant: string[];
8
+ };
9
+ };
10
+ export declare const getNonBusinessSegmentConfig: ({ segmentCode, segmentId, segmentTypeCode, }: {
11
+ segmentCode: string;
12
+ segmentTypeCode: string;
13
+ segmentId: string;
14
+ }) => {
15
+ payment_provider: {
16
+ technology: {
17
+ orchestrator: string[];
18
+ gateway?: undefined;
19
+ };
20
+ institution?: undefined;
21
+ };
22
+ platform?: undefined;
23
+ development_agency?: undefined;
24
+ } | {
25
+ payment_provider: {
26
+ technology: {
27
+ gateway: string[];
28
+ orchestrator?: undefined;
29
+ };
30
+ institution?: undefined;
31
+ };
32
+ platform?: undefined;
33
+ development_agency?: undefined;
34
+ } | {
35
+ payment_provider: {
36
+ institution: {
37
+ facilitator: string[];
38
+ acquirer?: undefined;
39
+ };
40
+ technology?: undefined;
41
+ };
42
+ platform?: undefined;
43
+ development_agency?: undefined;
44
+ } | {
45
+ payment_provider: {
46
+ institution: {
47
+ acquirer: string[];
48
+ facilitator?: undefined;
49
+ };
50
+ technology?: undefined;
51
+ };
52
+ platform?: undefined;
53
+ development_agency?: undefined;
54
+ } | {
55
+ platform: string[];
56
+ payment_provider?: undefined;
57
+ development_agency?: undefined;
58
+ } | {
59
+ development_agency: string[];
60
+ payment_provider?: undefined;
61
+ platform?: undefined;
62
+ } | {
63
+ payment_provider?: undefined;
64
+ platform?: undefined;
65
+ development_agency?: undefined;
66
+ };
@@ -1,7 +1,7 @@
1
+ import { SEGMENT_CODE } from '../types/index.js';
1
2
  import { getDefaultEntityCountry } from './entity';
2
3
  export const getSegmentData = (segments, activeSegmentId, activeSegments) => {
3
4
  var _a, _b, _c;
4
- // debugger
5
5
  const newSegment = (_a = segments.find((segment) => segment.id === activeSegmentId)) !== null && _a !== void 0 ? _a : {};
6
6
  const activeSegment = (_b = activeSegments.find((segment) => segment.id === activeSegmentId)) !== null && _b !== void 0 ? _b : {};
7
7
  const defaultCountry = activeSegment.countries.length === 1
@@ -11,3 +11,54 @@ export const getSegmentData = (segments, activeSegmentId, activeSegments) => {
11
11
  return Object.assign(Object.assign({}, newSegment), { defaultCountry,
12
12
  defaultEntity });
13
13
  };
14
+ export const getBusinessSegmentConfig = (merchantsIds) => {
15
+ if (!merchantsIds || !(merchantsIds === null || merchantsIds === void 0 ? void 0 : merchantsIds.length))
16
+ return {};
17
+ return { business: { merchant: merchantsIds } };
18
+ };
19
+ export const getNonBusinessSegmentConfig = ({ segmentCode, segmentId, segmentTypeCode, }) => {
20
+ const code = SEGMENT_CODE.PSP === segmentTypeCode ? segmentCode : segmentTypeCode;
21
+ if (code === SEGMENT_CODE.PAYMENT_TECHNOLOGY) {
22
+ return {
23
+ payment_provider: {
24
+ technology: {
25
+ orchestrator: [segmentId],
26
+ },
27
+ },
28
+ };
29
+ }
30
+ if (code === SEGMENT_CODE.PAYMENT_GATEWAY || code === SEGMENT_CODE.PAYMENT_GATEWAY_PROVIDER) {
31
+ return {
32
+ payment_provider: {
33
+ technology: {
34
+ gateway: [segmentId],
35
+ },
36
+ },
37
+ };
38
+ }
39
+ if (code === SEGMENT_CODE.PAYMENT_FACILITATOR) {
40
+ return {
41
+ payment_provider: {
42
+ institution: {
43
+ facilitator: [segmentId],
44
+ },
45
+ },
46
+ };
47
+ }
48
+ if (code === SEGMENT_CODE.PAYMENT_ACQUIRER) {
49
+ return {
50
+ payment_provider: {
51
+ institution: {
52
+ acquirer: [segmentId],
53
+ },
54
+ },
55
+ };
56
+ }
57
+ if (code === SEGMENT_CODE.PLATFORM) {
58
+ return { platform: [segmentId] };
59
+ }
60
+ if (code === SEGMENT_CODE.DEVELOPMENT) {
61
+ return { development_agency: [segmentId] };
62
+ }
63
+ return {};
64
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.329",
4
+ "version": "0.1.330",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",