@tap-payments/os-micro-frontend-shared 0.1.228 → 0.1.230

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,11 +1,13 @@
1
1
  import { TableHeaderStatus } from '../../types/index.js';
2
2
  import { AvailableStatus } from './type';
3
+ import { SxProps } from '@mui/material';
3
4
  interface StatusBarProps<IStatus extends TableHeaderStatus | TableHeaderStatus[] = undefined> {
4
5
  status?: IStatus;
5
6
  availableStatuses?: AvailableStatus<IStatus>[];
6
7
  isFilteredIdsShown?: boolean;
7
8
  onStatusChange?: (status?: IStatus) => void;
9
+ buttonSx?: SxProps;
8
10
  }
9
- declare function StatusBar<IStatus extends TableHeaderStatus | TableHeaderStatus[] = undefined>({ isFilteredIdsShown, availableStatuses, status, onStatusChange, }: Readonly<StatusBarProps<IStatus>>): import("react/jsx-runtime").JSX.Element;
11
+ declare function StatusBar<IStatus extends TableHeaderStatus | TableHeaderStatus[] = undefined>({ isFilteredIdsShown, availableStatuses, status, onStatusChange, buttonSx, }: Readonly<StatusBarProps<IStatus>>): import("react/jsx-runtime").JSX.Element;
10
12
  declare const _default: typeof StatusBar;
11
13
  export default _default;
@@ -14,7 +14,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { Fragment, memo, useCallback } from 'react';
15
15
  import { useTranslation } from 'react-i18next';
16
16
  import StatusButton from '../StatusButton';
17
- function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChange, }) {
17
+ function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChange, buttonSx, }) {
18
18
  const { t } = useTranslation();
19
19
  const getButtonStatus = useCallback((buttonStatus) => {
20
20
  return buttonStatus === status && !isFilteredIdsShown ? 'active' : 'inActive';
@@ -33,7 +33,7 @@ function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChan
33
33
  if (!Array.isArray(s.status)) {
34
34
  handleStatusChange(s.status);
35
35
  }
36
- } })));
36
+ }, buttonSx: buttonSx })));
37
37
  }
38
38
  const statusItems = s.status;
39
39
  if (!statusItems)
@@ -47,7 +47,7 @@ function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChan
47
47
  status: stat === null || stat === void 0 ? void 0 : stat.value,
48
48
  icon: stat.icon,
49
49
  onClick: () => handleStatusChange(stat.value),
50
- })) })) }, (_c = formattedStatuses[0]) === null || _c === void 0 ? void 0 : _c.value));
50
+ })), buttonSx: buttonSx })) }, (_c = formattedStatuses[0]) === null || _c === void 0 ? void 0 : _c.value));
51
51
  }) }));
52
52
  }
53
53
  export default memo(StatusBar);
@@ -19,7 +19,7 @@ import { ChevronContainer, Label, LabelWrapper, StyledStatusIcon, StyledDropdown
19
19
  import { statusButtonIcons } from './constant';
20
20
  const StatusButton = memo((props) => {
21
21
  var _a;
22
- const { variant = 'inActive', badgeCount, icon, label, dropdownOptions, selectedStatus: initialStatus, onButtonBodyClick, iconMapper = statusButtonIcons } = props, restProps = __rest(props, ["variant", "badgeCount", "icon", "label", "dropdownOptions", "selectedStatus", "onButtonBodyClick", "iconMapper"]);
22
+ const { variant = 'inActive', badgeCount, icon, label, dropdownOptions, selectedStatus: initialStatus, onButtonBodyClick, iconMapper = statusButtonIcons, buttonSx } = props, restProps = __rest(props, ["variant", "badgeCount", "icon", "label", "dropdownOptions", "selectedStatus", "onButtonBodyClick", "iconMapper", "buttonSx"]);
23
23
  const [buttonClicks, setButtonClicks] = useState(0);
24
24
  const { t } = useTranslation();
25
25
  const buttonRef = useRef(null);
@@ -75,6 +75,6 @@ const StatusButton = memo((props) => {
75
75
  const menuItems = useMemo(() => (dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((item) => (Object.assign(Object.assign({}, item), { onClick: handleMenuItemClick(item) })))) || [], [dropdownOptions, handleMenuItemClick]);
76
76
  const ButtonComponent = statusButtonVariants[variant];
77
77
  const displayLabel = selectedStatus ? t(selectedStatus) : label;
78
- return (_jsxs(_Fragment, { children: [_jsx(ButtonComponent, Object.assign({ "data-testid": "StatusButton" }, restProps, { ref: buttonRef, onClick: handleButtonClick, sx: Object.assign({}, (hasDropdown && { paddingInlineEnd: '27px' })) }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [statusIcon, displayLabel, statusBadge] })), dropdownIcon && _jsx(ChevronContainer, { children: dropdownIcon })] }) })), isDropdownOpen && hasDropdown && (_jsx(StyledDropdown, { open: isDropdownOpen, onClose: handleDropdownClose, anchorEl: anchorEl, menuItems: menuItems }))] }));
78
+ return (_jsxs(_Fragment, { children: [_jsx(ButtonComponent, Object.assign({ "data-testid": "StatusButton" }, restProps, { ref: buttonRef, onClick: handleButtonClick, sx: Object.assign(Object.assign({}, (hasDropdown && { paddingInlineEnd: '27px' })), buttonSx) }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [statusIcon, displayLabel, statusBadge] })), dropdownIcon && _jsx(ChevronContainer, { children: dropdownIcon })] }) })), isDropdownOpen && hasDropdown && (_jsx(StyledDropdown, { open: isDropdownOpen, onClose: handleDropdownClose, anchorEl: anchorEl, menuItems: menuItems }))] }));
79
79
  });
80
80
  export default StatusButton;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { type ButtonProps } from '@mui/material';
2
+ import { SxProps, type ButtonProps } from '@mui/material';
3
3
  import { TableHeaderStatus } from '../../types/index.js';
4
4
  import { type StatusButtonVariant } from './style';
5
5
  import { MenuItemI } from '../DropdownMenu';
@@ -29,6 +29,7 @@ export interface StatusButtonProps extends Omit<ButtonProps, 'variant' | 'childr
29
29
  dropdownOptions?: Array<MenuItemI & {
30
30
  status: TableHeaderStatus;
31
31
  }>;
32
+ buttonSx?: SxProps;
32
33
  }
33
34
  export interface ChevronIconProps {
34
35
  isActive?: boolean;
@@ -46,7 +46,7 @@ export declare const API_LIST_CONSTANTS: {
46
46
  readonly page: 1;
47
47
  };
48
48
  readonly brands: {
49
- readonly limit: 20;
49
+ readonly limit: 50;
50
50
  };
51
51
  readonly MerchantsList: {
52
52
  readonly limit: 50;
@@ -46,7 +46,7 @@ export const API_LIST_CONSTANTS = {
46
46
  page: 1,
47
47
  },
48
48
  brands: {
49
- limit: 20,
49
+ limit: 50,
50
50
  },
51
51
  MerchantsList: {
52
52
  limit: API_BASE_LIMIT,
@@ -371,11 +371,11 @@ export const APP_DIMENSIONS = {
371
371
  maxHeight: '100vh',
372
372
  },
373
373
  [APP_CODES.reports.code]: {
374
- width: 500,
375
- minWidth: 500,
374
+ width: 700,
375
+ minWidth: 700,
376
376
  maxWidth: 'unset',
377
377
  maxHeight: 'unset',
378
- height: 600,
378
+ height: 652,
379
379
  },
380
380
  [APP_CODES.billing.code]: {
381
381
  minWidth: 856,
@@ -556,3 +556,4 @@ export declare const inActiveGreyIcon: string;
556
556
  export declare const terminalLinkVideo: string;
557
557
  export declare const bluePlusIcon: string;
558
558
  export declare const blackSettingsVariant2Icon: string;
559
+ export declare const exclamationWhiteIcon: string;
@@ -564,3 +564,4 @@ export const inActiveGreyIcon = `${lightUrl}/inActiveGreyIcon.svg`;
564
564
  export const terminalLinkVideo = `${videosUrl}/terminal_link.mp4`;
565
565
  export const bluePlusIcon = `${lightUrl}/bluePlusIcon.svg`;
566
566
  export const blackSettingsVariant2Icon = `${lightUrl}/blackSettingsVariant2Icon.svg`;
567
+ export const exclamationWhiteIcon = `${lightUrl}/exclamationWhite.svg`;
@@ -38,3 +38,7 @@ export declare const generatePastYearList: (length?: number) => {
38
38
  label: number;
39
39
  }[];
40
40
  export declare function secondsToTimeString(seconds: number): string;
41
+ type TimeUnit = 'seconds' | 'minutes' | 'hours' | 'days';
42
+ export declare function isWithinTimeAgo(timestampMs: number, amount: number, unit?: TimeUnit): boolean;
43
+ export declare const formatRelativeTimeWithinHour: (timestampMs: number) => string;
44
+ export {};
@@ -216,3 +216,24 @@ export function secondsToTimeString(seconds) {
216
216
  }
217
217
  return `${pad(minutes)}:${pad(secondsValue)}`;
218
218
  }
219
+ export function isWithinTimeAgo(timestampMs, amount, unit = 'seconds') {
220
+ const unitSeconds = {
221
+ seconds: 1,
222
+ minutes: 60,
223
+ hours: 3600,
224
+ days: 86400,
225
+ };
226
+ const now = Date.now();
227
+ const diffSeconds = (now - timestampMs) / 1000;
228
+ return diffSeconds < amount * unitSeconds[unit];
229
+ }
230
+ export const formatRelativeTimeWithinHour = (timestampMs) => {
231
+ const now = Date.now();
232
+ const diffSeconds = Math.floor((now - timestampMs) / 1000);
233
+ const diffMinutes = Math.floor(diffSeconds / 60);
234
+ if (isWithinTimeAgo(timestampMs, 60, 'seconds'))
235
+ return 'just now';
236
+ if (isWithinTimeAgo(timestampMs, 60, 'minutes'))
237
+ return `${diffMinutes} min${diffMinutes === 1 ? '' : 's'} ago`;
238
+ return '1 hour ago'; // fallback for > 59 mins
239
+ };
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.228",
4
+ "version": "0.1.230",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",