@tap-payments/os-micro-frontend-shared 0.1.227 → 0.1.228-test.2
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.
- package/build/components/Autocomplete/Autocomplete.d.ts +1 -1
- package/build/components/Chip/style.d.ts +0 -1
- package/build/components/CountBadge/style.d.ts +0 -1
- package/build/components/Dialog/style.d.ts +0 -1
- package/build/components/FlippingCard/style.d.ts +0 -1
- package/build/components/ImageWrapper/ImageWrapper.d.ts +0 -1
- package/build/components/JSONViewer/style.d.ts +0 -1
- package/build/components/LeftPeekRightExpandingChip/style.d.ts +0 -1
- package/build/components/RightLeftExpandingCenterChip/style.d.ts +0 -1
- package/build/components/RightLeftExpandingCenterChip/style.js +1 -1
- package/build/components/SearchButton/styles.d.ts +0 -1
- package/build/components/StatusBar/StatusBar.d.ts +3 -1
- package/build/components/StatusBar/StatusBar.js +3 -3
- package/build/components/StatusButton/StatusButton.js +2 -2
- package/build/components/StatusButton/type.d.ts +2 -1
- package/build/components/StatusIcons/AuthIcons/style.d.ts +0 -1
- package/build/components/StatusIcons/AuthorizationAutoIcons/style.d.ts +0 -1
- package/build/components/StatusIcons/ChargeStatusIcon/style.d.ts +0 -1
- package/build/components/StatusIcons/SourceIcons/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ApplicationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationTypeCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/BalanceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ChannelsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/CheckoutStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/DestinationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/DueDateCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/IDButton/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/IntentsStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/PayoutStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ProductsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ReferenceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/RefundChargeCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/RefundStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SalesChannelCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SegmentsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SourceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/StatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/TokenStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/style.d.ts +0 -1
- package/build/components/VirtualTables/components/style.d.ts +0 -1
- package/build/components/index.d.ts +1 -0
- package/build/components/index.js +1 -0
- package/build/constants/apps.js +3 -3
- package/build/constants/assets.d.ts +1 -0
- package/build/constants/assets.js +1 -0
- package/build/utils/date.d.ts +4 -0
- package/build/utils/date.js +21 -0
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AutocompleteRenderInputParams, AutocompleteProps as MuiAutocompleteProps } from '@mui/material/Autocomplete';
|
|
3
3
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
4
|
-
import { MakeOptional } from '
|
|
4
|
+
import { MakeOptional } from '../../types/index.js';
|
|
5
5
|
export type AutocompleteProps<Value = string, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = 'div'> = {
|
|
6
6
|
label?: TextFieldProps['label'];
|
|
7
7
|
textFieldProps?: TextFieldProps | ((params: AutocompleteRenderInputParams) => TextFieldProps);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
import { GetSourceAnimationFunction } from './type';
|
|
4
3
|
export declare const ChipStyled: import("@emotion/styled").StyledComponent<import("react").RefAttributes<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
5
4
|
variant?: import("./type").ChipVariant | undefined;
|
|
@@ -92,7 +92,7 @@ export const CenterContent = styled(motion.span)(() => ({
|
|
|
92
92
|
export const ExpandableContainer = styled(motion.span)(({ theme }) => ({
|
|
93
93
|
display: 'inline-flex',
|
|
94
94
|
whiteSpace: 'nowrap',
|
|
95
|
-
overflow: 'hidden',
|
|
95
|
+
// overflow: 'hidden',
|
|
96
96
|
boxSizing: 'border-box',
|
|
97
97
|
willChange: 'width',
|
|
98
98
|
// Style to look like a seamless continuation of the center chip
|
|
@@ -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;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
import { TableMode } from '../../../../types/index.js';
|
|
4
3
|
export declare const ActionCellContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
5
4
|
tableMode?: TableMode | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledAppsCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const AppsStatusContainer: import("@emotion/styled").StyledComponent<{
|
|
5
4
|
hidden?: boolean | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const AuthIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
4
3
|
export declare const AuthCellContainer: import("@emotion/styled").StyledComponent<{
|
|
5
4
|
hidden?: boolean | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const ReferenceSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const SalesChannelsContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const ReferenceSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
5
4
|
hidden?: boolean | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
3
|
export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
5
4
|
export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const GeographyBox: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
4
3
|
variant?: "Global" | "Regional" | "Local" | undefined;
|
|
5
4
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
package/build/constants/apps.js
CHANGED
|
@@ -371,11 +371,11 @@ export const APP_DIMENSIONS = {
|
|
|
371
371
|
maxHeight: '100vh',
|
|
372
372
|
},
|
|
373
373
|
[APP_CODES.reports.code]: {
|
|
374
|
-
width:
|
|
375
|
-
minWidth:
|
|
374
|
+
width: 700,
|
|
375
|
+
minWidth: 700,
|
|
376
376
|
maxWidth: 'unset',
|
|
377
377
|
maxHeight: 'unset',
|
|
378
|
-
height:
|
|
378
|
+
height: 652,
|
|
379
379
|
},
|
|
380
380
|
[APP_CODES.billing.code]: {
|
|
381
381
|
minWidth: 856,
|
|
@@ -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`;
|
package/build/utils/date.d.ts
CHANGED
|
@@ -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 {};
|
package/build/utils/date.js
CHANGED
|
@@ -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,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.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.228-test.2",
|
|
5
|
+
"testVersion": 2,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
@@ -163,4 +163,4 @@
|
|
|
163
163
|
"publishConfig": {
|
|
164
164
|
"registry": "https://registry.npmjs.org/"
|
|
165
165
|
}
|
|
166
|
-
}
|
|
166
|
+
}
|