@tap-payments/auth-jsconnect 2.11.6-development → 2.11.8-development

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.
@@ -9,10 +9,7 @@ export interface GenerateAuthLinkNewTerminalProps {
9
9
  export interface UnlinkTerminalDeviceProps {
10
10
  deviceId: string;
11
11
  initiator: string;
12
- terminal: {
13
- id: string;
14
- };
15
- merchant: {
12
+ device: {
16
13
  id: string;
17
14
  };
18
15
  }
@@ -43,7 +43,7 @@ var unlinkTerminalDevice = function (_a) {
43
43
  var deviceId = _a.deviceId, payload = __rest(_a, ["deviceId"]);
44
44
  return httpClient({
45
45
  method: 'put',
46
- url: "".concat(ENDPOINT_PATHS.TERMINAL, "/device/").concat(deviceId, "/unlink"),
46
+ url: "".concat(ENDPOINT_PATHS.TERMINAL, "/").concat(deviceId, "/unlink"),
47
47
  data: payload
48
48
  });
49
49
  };
@@ -23,13 +23,13 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import { memo } from 'react';
25
25
  import { useTranslation } from 'react-i18next';
26
- import { alpha, styled } from '@mui/material/styles';
26
+ import { alpha, styled, useTheme } from '@mui/material/styles';
27
27
  import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
28
28
  import Card from '@mui/material/Card';
29
29
  import Box from '@mui/material/Box';
30
- import Typography from '@mui/material/Typography';
31
30
  import Icon from '../Icon';
32
31
  import Loader from '../Loader';
32
+ import TruncatedTooltipText from '../TruncatedTooltipText';
33
33
  var DeviceCardContainer = styled(Card, { shouldForwardProp: function (prop) { return !['showBorder'].includes(prop.toString()); } })(function (_a) {
34
34
  var _b = _a.theme, spacing = _b.spacing, _c = _b.palette, background = _c.background, components = _c.components, showBorder = _a.showBorder;
35
35
  return (__assign({ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: spacing(2), borderRadius: spacing(0.5), boxShadow: 'none', width: '100%', backgroundColor: background.default, minHeight: spacing(14.125), position: 'relative' }, (showBorder && {
@@ -41,7 +41,8 @@ var DeviceDetails = styled(Box)(function (_a) {
41
41
  return ({
42
42
  display: 'flex',
43
43
  alignItems: 'center',
44
- gap: spacing(3.125)
44
+ gap: spacing(3.125),
45
+ width: '90%'
45
46
  });
46
47
  });
47
48
  var DeviceImage = styled(Icon)(function (_a) {
@@ -57,13 +58,10 @@ var DeviceInfo = styled(Box)(function (_a) {
57
58
  return ({
58
59
  display: 'flex',
59
60
  flexDirection: 'column',
60
- gap: spacing(1)
61
+ gap: spacing(1),
62
+ width: '80%'
61
63
  });
62
64
  });
63
- var DeviceTitle = styled(Typography)(function (_a) {
64
- var _b = _a.theme, typography = _b.typography, palette = _b.palette;
65
- return (__assign(__assign({}, typography.subtitle1), { color: palette.components.deviceCard.title, fontWeight: typography.fontWeightBold }));
66
- });
67
65
  var DeviceIdInfo = styled(Box)(function (_a) {
68
66
  var _b = _a.theme, typography = _b.typography, palette = _b.palette, spacing = _b.spacing;
69
67
  return (__assign(__assign({}, typography.caption_small), { color: alpha(palette.text.primary, 0.6), display: 'flex', flexDirection: 'column', gap: spacing(0.5) }));
@@ -90,6 +88,7 @@ var ArrowIcon = styled(ArrowForwardIosIcon)(function (_a) {
90
88
  export var DeviceCard = function (_a) {
91
89
  var image = _a.image, name = _a.name, deviceId = _a.deviceId, deviceIdLabel = _a.deviceIdLabel, isLinked = _a.isLinked, pairedWith = _a.pairedWith, onClick = _a.onClick, badge = _a.badge, border = _a.border, arrow = _a.arrow, loading = _a.loading, endAdornment = _a.endAdornment, rest = __rest(_a, ["image", "name", "deviceId", "deviceIdLabel", "isLinked", "pairedWith", "onClick", "badge", "border", "arrow", "loading", "endAdornment"]);
92
90
  var t = useTranslation().t;
91
+ var _b = useTheme(), typography = _b.typography, palette = _b.palette;
93
92
  var getEndComponent = function () {
94
93
  if (endAdornment)
95
94
  return endAdornment;
@@ -98,6 +97,6 @@ export var DeviceCard = function (_a) {
98
97
  if (arrow)
99
98
  return _jsx(ArrowIcon, {});
100
99
  };
101
- return (_jsxs(DeviceCardContainer, __assign({ onClick: onClick, sx: { cursor: onClick ? 'pointer' : 'default' }, showBorder: border }, rest, { children: [_jsxs(DeviceDetails, { children: [image && _jsx(DeviceImage, { src: image, alt: 'Device' }), _jsxs(DeviceInfo, { children: [_jsx(DeviceTitle, { children: name }), _jsxs(DeviceIdInfo, { children: [pairedWith && (_jsxs("span", { children: [t('terminal_paired_with'), ": ", _jsx(DeviceIdBold, { children: pairedWith })] })), _jsxs("span", { children: [t(deviceIdLabel !== null && deviceIdLabel !== void 0 ? deviceIdLabel : 'terminal_device_id'), ": ", _jsx(DeviceIdBold, { children: deviceId })] })] })] })] }), badge && _jsx(Badge, __assign({ active: isLinked }, { children: isLinked ? t('terminal_linked') : t('terminal_unlinked') })), _jsx(Box, __assign({ display: 'flex', alignItems: 'center' }, { children: getEndComponent() }))] })));
100
+ return (_jsxs(DeviceCardContainer, __assign({ onClick: onClick, sx: { cursor: onClick ? 'pointer' : 'default' }, showBorder: border }, rest, { children: [_jsxs(DeviceDetails, { children: [image && _jsx(DeviceImage, { src: image, alt: 'Device' }), _jsxs(DeviceInfo, { children: [_jsx(TruncatedTooltipText, { text: name, style: __assign(__assign({}, typography.subtitle1), { color: palette.components.deviceCard.title, fontWeight: typography.fontWeightBold }) }), _jsxs(DeviceIdInfo, { children: [pairedWith && (_jsxs("span", { children: [t('terminal_paired_with'), ": ", _jsx(DeviceIdBold, { children: pairedWith })] })), _jsxs("span", { children: [t(deviceIdLabel !== null && deviceIdLabel !== void 0 ? deviceIdLabel : 'terminal_device_id'), ": ", _jsx(DeviceIdBold, { children: deviceId })] })] })] })] }), badge && _jsx(Badge, __assign({ active: isLinked }, { children: isLinked ? t('terminal_linked') : t('terminal_unlinked') })), _jsx(Box, __assign({ display: 'flex', alignItems: 'center' }, { children: getEndComponent() }))] })));
102
101
  };
103
102
  export default memo(DeviceCard);
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface TruncatedTooltipTextProps {
3
+ text: string;
4
+ style?: React.CSSProperties;
5
+ }
6
+ declare const TruncatedTooltipText: ({ text, style }: TruncatedTooltipTextProps) => JSX.Element;
7
+ export default TruncatedTooltipText;
@@ -0,0 +1,36 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { useRef, useState, useEffect } from 'react';
14
+ import Tooltip from '../Tooltip';
15
+ var TruncatedTooltipText = function (_a) {
16
+ var text = _a.text, style = _a.style;
17
+ var textRef = useRef(null);
18
+ var _b = useState(false), isTruncated = _b[0], setIsTruncated = _b[1];
19
+ var _c = useState(false), hasSpace = _c[0], setHasSpace = _c[1];
20
+ useEffect(function () {
21
+ if (text.includes(' ')) {
22
+ setHasSpace(true);
23
+ return;
24
+ }
25
+ var el = textRef === null || textRef === void 0 ? void 0 : textRef.current;
26
+ if (el) {
27
+ setIsTruncated(el.scrollWidth > el.clientWidth);
28
+ }
29
+ if (text.includes(' ')) {
30
+ setHasSpace(true);
31
+ }
32
+ }, [text]);
33
+ var content = (_jsx("span", __assign({ ref: textRef, style: __assign({ whiteSpace: hasSpace ? 'break-spaces' : 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', display: 'block' }, style) }, { children: text })));
34
+ return isTruncated ? (_jsx(Tooltip, __assign({ title: text, placement: 'top' }, { children: content }))) : (content);
35
+ };
36
+ export default TruncatedTooltipText;
@@ -0,0 +1,2 @@
1
+ import TruncatedTooltipText from './TruncatedTooltipText';
2
+ export default TruncatedTooltipText;
@@ -0,0 +1,2 @@
1
+ import TruncatedTooltipText from './TruncatedTooltipText';
2
+ export default TruncatedTooltipText;
@@ -248,20 +248,16 @@ export var pushNotificationLinkNewTerminal = createAsyncThunk('terminal/pushNoti
248
248
  });
249
249
  });
250
250
  export var unlinkTerminalDevice = createAsyncThunk('terminal/unlinkTerminalDevice', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
251
- var terminal, _a, id, terminal_device, merchant, payload, data;
251
+ var _a, id, device, payload, data;
252
252
  return __generator(this, function (_b) {
253
253
  switch (_b.label) {
254
254
  case 0:
255
- terminal = thunkApi.getState().terminal;
256
- _a = terminal.data.terminalInfo.selectedTerminal, id = _a.id, terminal_device = _a.terminal_device, merchant = _a.merchant;
255
+ _a = thunkApi.getState().terminal.data.terminalInfo.selectedTerminal, id = _a.id, device = _a.device;
257
256
  payload = {
258
257
  deviceId: id,
259
- initiator: 'connect',
260
- terminal: {
261
- id: terminal_device.id
262
- },
263
- merchant: {
264
- id: (merchant === null || merchant === void 0 ? void 0 : merchant.id) || ''
258
+ initiator: 'terminal_device',
259
+ device: {
260
+ id: (device === null || device === void 0 ? void 0 : device.id) || ''
265
261
  }
266
262
  };
267
263
  return [4, API.terminalService.unlinkTerminalDevice(payload)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.11.6-development",
3
+ "version": "2.11.8-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",