@tap-payments/os-micro-frontend-shared 0.1.290 → 0.1.291

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,10 @@
1
+ import { CustomColumnFilterProps } from '../VirtualTables';
2
+ export interface CurrencyFilterProps extends CustomColumnFilterProps {
3
+ onConfirm: (currencies?: string[]) => void;
4
+ currencies?: string[];
5
+ onCurrenciesChange: (currencies?: string[]) => void;
6
+ merchantCurrencies: {
7
+ currencyCode: string;
8
+ }[];
9
+ }
10
+ export default function CurrencyFilter({ currencies, onCurrenciesChange, merchantCurrencies, anchorEl, onCloseDropdown, onConfirm, }: Readonly<CurrencyFilterProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import uniqBy from 'lodash/uniqBy';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { CountryFlag, Menu, MenuItem, FilterCancelButton, FilterFooter, FilterOkayButton, FilterTitle } from '../index.js';
6
+ export default function CurrencyFilter({ currencies, onCurrenciesChange, merchantCurrencies, anchorEl, onCloseDropdown, onConfirm, }) {
7
+ const open = Boolean(anchorEl);
8
+ const { t } = useTranslation();
9
+ const uniqueCurrencies = useMemo(() => uniqBy(merchantCurrencies, 'currencyCode'), [merchantCurrencies]);
10
+ const handleOkButtonClick = (e) => {
11
+ onConfirm(currencies);
12
+ onCloseDropdown(e);
13
+ };
14
+ const checkIsSelected = (currencyCode) => { var _a; return (_a = currencies === null || currencies === void 0 ? void 0 : currencies.includes(currencyCode)) !== null && _a !== void 0 ? _a : false; };
15
+ const onClickCurrency = (currencyCode) => {
16
+ var _a;
17
+ if ((currencies === null || currencies === void 0 ? void 0 : currencies.indexOf(currencyCode)) !== -1) {
18
+ const newCurrencies = (_a = currencies === null || currencies === void 0 ? void 0 : currencies.filter((currency) => currency !== currencyCode)) !== null && _a !== void 0 ? _a : [];
19
+ onCurrenciesChange(newCurrencies.length > 0 ? newCurrencies : []);
20
+ return;
21
+ }
22
+ onCurrenciesChange([...currencies, currencyCode]);
23
+ };
24
+ return (_jsxs(Menu, Object.assign({ open: open, anchorEl: anchorEl, sx: { marginTop: '8px', marginBottom: '8px' } }, { children: [_jsx(FilterTitle, Object.assign({ component: "span" }, { children: t('filterBy') })), uniqueCurrencies.map(({ currencyCode }) => (_jsxs(MenuItem, Object.assign({ isSelected: checkIsSelected(currencyCode), onClick: () => {
25
+ onClickCurrency(currencyCode);
26
+ } }, { children: [_jsx(CountryFlag, { currencyCode: currencyCode }), currencyCode] }), currencyCode))), _jsxs(FilterFooter, { children: [_jsx(FilterCancelButton, Object.assign({ onClick: onCloseDropdown }, { children: t('cancel') })), _jsx(FilterOkayButton, Object.assign({ onClick: handleOkButtonClick }, { children: t('okay') }))] })] })));
27
+ }
@@ -0,0 +1 @@
1
+ export { default as CurrencyFilter, type CurrencyFilterProps } from './CurrencyFilter';
@@ -0,0 +1 @@
1
+ export { default as CurrencyFilter } from './CurrencyFilter';
@@ -145,3 +145,4 @@ export { default as TableReports } from './TableReports';
145
145
  export * from './TableReports';
146
146
  export * from './PaymentSourceFilter';
147
147
  export * from './DateFilter';
148
+ export * from './CurrencyFilter';
@@ -145,3 +145,4 @@ export { default as TableReports } from './TableReports';
145
145
  export * from './TableReports';
146
146
  export * from './PaymentSourceFilter';
147
147
  export * from './DateFilter';
148
+ export * from './CurrencyFilter';
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.290",
4
+ "version": "0.1.291",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",