@tap-payments/auth-jsconnect 2.13.10-beta → 2.14.0-beta
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/@types/app.d.ts +2 -1
- package/build/@types/app.js +1 -0
- package/build/@types/index.d.ts +1 -0
- package/build/@types/index.js +1 -0
- package/build/@types/terminal.d.ts +104 -0
- package/build/@types/terminal.js +1 -0
- package/build/api/auth.d.ts +15 -1
- package/build/api/index.d.ts +7 -1
- package/build/api/index.js +3 -1
- package/build/api/terminal.d.ts +25 -0
- package/build/api/terminal.js +55 -0
- package/build/app/rootReducer.d.ts +1 -0
- package/build/app/rootReducer.js +3 -1
- package/build/app/store.d.ts +2 -0
- package/build/assets/locales/en.json +0 -1
- package/build/components/DeviceCard/DeviceCard.d.ts +19 -0
- package/build/components/DeviceCard/DeviceCard.js +102 -0
- package/build/components/DeviceCard/index.d.ts +3 -0
- package/build/components/DeviceCard/index.js +2 -0
- package/build/components/OTPTimer/OTPTimer.d.ts +2 -1
- package/build/components/OTPTimer/OTPTimer.js +4 -4
- package/build/components/TruncatedTooltipText/TruncatedTooltipText.d.ts +7 -0
- package/build/components/TruncatedTooltipText/TruncatedTooltipText.js +33 -0
- package/build/components/TruncatedTooltipText/index.d.ts +2 -0
- package/build/components/TruncatedTooltipText/index.js +2 -0
- package/build/constants/app.d.ts +12 -1
- package/build/constants/app.js +133 -0
- package/build/constants/flows.d.ts +16 -0
- package/build/constants/flows.js +16 -0
- package/build/constants/validation.d.ts +1 -0
- package/build/constants/validation.js +1 -0
- package/build/features/app/terminal/terminalStore.d.ts +110 -0
- package/build/features/app/terminal/terminalStore.js +703 -0
- package/build/features/featuresScreens.d.ts +1 -0
- package/build/features/featuresScreens.js +72 -0
- package/build/features/shared/Button/Button.js +1 -1
- package/build/features/shared/Button/FlowsButtons.d.ts +1 -0
- package/build/features/shared/Button/FlowsButtons.js +2 -2
- package/build/features/shared/PushNotification/PushNotification.d.ts +11 -0
- package/build/features/shared/PushNotification/PushNotification.js +34 -0
- package/build/features/shared/PushNotification/index.d.ts +2 -0
- package/build/features/shared/PushNotification/index.js +2 -0
- package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.d.ts +2 -1
- package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +5 -4
- package/build/features/shared/SuccessScreen/SuccessScreen.d.ts +3 -1
- package/build/features/shared/SuccessScreen/SuccessScreen.js +2 -2
- package/build/features/terminal/Terminal.d.ts +14 -0
- package/build/features/terminal/Terminal.js +95 -0
- package/build/features/terminal/index.d.ts +1 -0
- package/build/features/terminal/index.js +1 -0
- package/build/features/terminal/screens/LinkNewTerminal/LinkNewTerminal.d.ts +3 -0
- package/build/features/terminal/screens/LinkNewTerminal/LinkNewTerminal.js +68 -0
- package/build/features/terminal/screens/LinkNewTerminal/index.d.ts +2 -0
- package/build/features/terminal/screens/LinkNewTerminal/index.js +2 -0
- package/build/features/terminal/screens/LinkNewTerminal/styles.d.ts +10 -0
- package/build/features/terminal/screens/LinkNewTerminal/styles.js +28 -0
- package/build/features/terminal/screens/LinkedSuccess/LinkedSuccess.d.ts +3 -0
- package/build/features/terminal/screens/LinkedSuccess/LinkedSuccess.js +50 -0
- package/build/features/terminal/screens/LinkedSuccess/index.d.ts +2 -0
- package/build/features/terminal/screens/LinkedSuccess/index.js +2 -0
- package/build/features/terminal/screens/LinkedTerminalInfo/LinkedTerminalInfo.d.ts +3 -0
- package/build/features/terminal/screens/LinkedTerminalInfo/LinkedTerminalInfo.js +55 -0
- package/build/features/terminal/screens/LinkedTerminalInfo/index.d.ts +2 -0
- package/build/features/terminal/screens/LinkedTerminalInfo/index.js +2 -0
- package/build/features/terminal/screens/Loading/Loading.d.ts +4 -0
- package/build/features/terminal/screens/Loading/Loading.js +10 -0
- package/build/features/terminal/screens/Loading/index.d.ts +2 -0
- package/build/features/terminal/screens/Loading/index.js +2 -0
- package/build/features/terminal/screens/NoTerminalDeviceLinked/NoTerminalDeviceLinked.d.ts +3 -0
- package/build/features/terminal/screens/NoTerminalDeviceLinked/NoTerminalDeviceLinked.js +103 -0
- package/build/features/terminal/screens/NoTerminalDeviceLinked/index.d.ts +2 -0
- package/build/features/terminal/screens/NoTerminalDeviceLinked/index.js +2 -0
- package/build/features/terminal/screens/NoTerminalDeviceLinked/styles.d.ts +36 -0
- package/build/features/terminal/screens/NoTerminalDeviceLinked/styles.js +34 -0
- package/build/features/terminal/screens/OperatorError/OperatorError.d.ts +5 -0
- package/build/features/terminal/screens/OperatorError/OperatorError.js +9 -0
- package/build/features/terminal/screens/OperatorError/index.d.ts +2 -0
- package/build/features/terminal/screens/OperatorError/index.js +2 -0
- package/build/features/terminal/screens/POSDeviceListPage/POSDeviceListPage.d.ts +3 -0
- package/build/features/terminal/screens/POSDeviceListPage/POSDeviceListPage.js +50 -0
- package/build/features/terminal/screens/POSDeviceListPage/index.d.ts +2 -0
- package/build/features/terminal/screens/POSDeviceListPage/index.js +2 -0
- package/build/features/terminal/screens/ResetPasswordSuccess/ResetPasswordSuccess.d.ts +3 -0
- package/build/features/terminal/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +21 -0
- package/build/features/terminal/screens/ResetPasswordSuccess/index.d.ts +2 -0
- package/build/features/terminal/screens/ResetPasswordSuccess/index.js +2 -0
- package/build/features/terminal/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.d.ts +3 -0
- package/build/features/terminal/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +32 -0
- package/build/features/terminal/screens/SuccessWithFlowButtons/index.d.ts +2 -0
- package/build/features/terminal/screens/SuccessWithFlowButtons/index.js +2 -0
- package/build/features/terminal/screens/TerminalDeviceList/DeviceList.d.ts +9 -0
- package/build/features/terminal/screens/TerminalDeviceList/DeviceList.js +20 -0
- package/build/features/terminal/screens/TerminalDeviceList/TerminalDeviceList.d.ts +3 -0
- package/build/features/terminal/screens/TerminalDeviceList/TerminalDeviceList.js +153 -0
- package/build/features/terminal/screens/TerminalDeviceList/index.d.ts +2 -0
- package/build/features/terminal/screens/TerminalDeviceList/index.js +2 -0
- package/build/features/terminal/screens/TerminalDeviceList/styles.d.ts +9 -0
- package/build/features/terminal/screens/TerminalDeviceList/styles.js +13 -0
- package/build/features/terminal/screens/UnlinkedSuccess/UnlinkedSuccess.d.ts +3 -0
- package/build/features/terminal/screens/UnlinkedSuccess/UnlinkedSuccess.js +51 -0
- package/build/features/terminal/screens/UnlinkedSuccess/index.d.ts +2 -0
- package/build/features/terminal/screens/UnlinkedSuccess/index.js +2 -0
- package/build/features/terminal/screens/UnlinkedTerminalInfo/UnlinkedTerminalInfo.d.ts +3 -0
- package/build/features/terminal/screens/UnlinkedTerminalInfo/UnlinkedTerminalInfo.js +99 -0
- package/build/features/terminal/screens/UnlinkedTerminalInfo/index.d.ts +2 -0
- package/build/features/terminal/screens/UnlinkedTerminalInfo/index.js +2 -0
- package/build/features/terminal/screens/UnlinkedTerminalInfo/styles.d.ts +26 -0
- package/build/features/terminal/screens/UnlinkedTerminalInfo/styles.js +30 -0
- package/build/features/terminal/screens/Verify/OTPInput.d.ts +7 -0
- package/build/features/terminal/screens/Verify/OTPInput.js +51 -0
- package/build/features/terminal/screens/Verify/Verify.d.ts +5 -0
- package/build/features/terminal/screens/Verify/Verify.js +89 -0
- package/build/features/terminal/screens/Verify/index.d.ts +2 -0
- package/build/features/terminal/screens/Verify/index.js +2 -0
- package/build/features/terminal/screens/Verify/validation.d.ts +8 -0
- package/build/features/terminal/screens/Verify/validation.js +4 -0
- package/build/features/terminal/screens/shared/Header.d.ts +10 -0
- package/build/features/terminal/screens/shared/Header.js +30 -0
- package/build/features/terminal/screens/shared/POSDeviceList.d.ts +11 -0
- package/build/features/terminal/screens/shared/POSDeviceList.js +30 -0
- package/build/features/terminal/screens/shared/index.d.ts +5 -0
- package/build/features/terminal/screens/shared/index.js +5 -0
- package/build/features/terminal/screens/shared/styles.d.ts +196 -0
- package/build/features/terminal/screens/shared/styles.js +155 -0
- package/build/features/terminal/screens/shared/utils.d.ts +7 -0
- package/build/features/terminal/screens/shared/utils.js +24 -0
- package/build/hooks/useAppDispatch.d.ts +1 -0
- package/build/index.d.ts +3 -2
- package/build/index.js +4 -2
- package/build/theme/palette.js +12 -0
- package/build/theme/typography.js +4 -0
- package/build/utils/error.d.ts +1 -0
- package/build/utils/error.js +3 -0
- package/build/utils/string.d.ts +2 -1
- package/build/utils/string.js +11 -2
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import * as React from 'react';
|
|
50
|
+
import { useTranslation } from 'react-i18next';
|
|
51
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
52
|
+
import { CONNECT_FLOWS } from '../../../../constants';
|
|
53
|
+
import { handleNextScreenStep, handlePrevScreenStep } from '../../../../app/settings';
|
|
54
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
55
|
+
import Button from '../../../../components/Button';
|
|
56
|
+
import Loader from '../../../../components/Loader';
|
|
57
|
+
import Warning from '../../../../components/Warning';
|
|
58
|
+
import Box from '@mui/material/Box';
|
|
59
|
+
import { clearError, resetTerminalLinkResponse, retrieveBoardDetails, retrieveBoardStatus, retrievePOSDevices, storeSelectedTerminal, terminalSelector } from '../../../app/terminal/terminalStore';
|
|
60
|
+
import { Header, Container, TextTypography } from '../shared';
|
|
61
|
+
import DeviceList from './DeviceList';
|
|
62
|
+
var TerminalDeviceList = function () {
|
|
63
|
+
var t = useTranslation().t;
|
|
64
|
+
var dispatch = useAppDispatch();
|
|
65
|
+
var _a = useAppSelector(terminalSelector), data = _a.data, loading = _a.loading, posDevicesLoading = _a.posDevicesLoading, error = _a.error;
|
|
66
|
+
var _b = React.useState(false), newLinkClicked = _b[0], setNewLinkClicked = _b[1];
|
|
67
|
+
var _c = data.responseData || {}, boardFlows = _c.boardFlows, authData = _c.authData, boardData = _c.boardData, terminalData = _c.terminalData, posDevices = _c.posDevices;
|
|
68
|
+
var list = (terminalData || {}).list;
|
|
69
|
+
var _d = React.useMemo(function () {
|
|
70
|
+
var linked = list === null || list === void 0 ? void 0 : list.filter(function (d) { return d.linked; });
|
|
71
|
+
var unLinked = list === null || list === void 0 ? void 0 : list.filter(function (d) { return !d.linked; });
|
|
72
|
+
return { linkedDevices: linked, unLinkedDevices: unLinked };
|
|
73
|
+
}, [list]), linkedDevices = _d.linkedDevices, unLinkedDevices = _d.unLinkedDevices;
|
|
74
|
+
var handleOnClickNewTerminalLink = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
setNewLinkClicked(true);
|
|
79
|
+
return [4, retrievePOSDevicesAsync(CONNECT_FLOWS.terminal.posDeviceList)];
|
|
80
|
+
case 1:
|
|
81
|
+
_a.sent();
|
|
82
|
+
return [2];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}); };
|
|
86
|
+
React.useEffect(function () {
|
|
87
|
+
if (error)
|
|
88
|
+
dispatch(clearError());
|
|
89
|
+
dispatch(resetTerminalLinkResponse());
|
|
90
|
+
}, []);
|
|
91
|
+
var retrievePOSDevicesAsync = function (nextScreen) { return __awaiter(void 0, void 0, void 0, function () {
|
|
92
|
+
var err_1;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
if (posDevices === null || posDevices === void 0 ? void 0 : posDevices.length) {
|
|
97
|
+
dispatch(handleNextScreenStep(nextScreen));
|
|
98
|
+
return [2];
|
|
99
|
+
}
|
|
100
|
+
_a.label = 1;
|
|
101
|
+
case 1:
|
|
102
|
+
_a.trys.push([1, 3, , 4]);
|
|
103
|
+
return [4, dispatch(retrievePOSDevices()).unwrap()];
|
|
104
|
+
case 2:
|
|
105
|
+
_a.sent();
|
|
106
|
+
dispatch(handleNextScreenStep(nextScreen));
|
|
107
|
+
return [3, 4];
|
|
108
|
+
case 3:
|
|
109
|
+
err_1 = _a.sent();
|
|
110
|
+
console.log('Error while retrieving terminal list error', err_1);
|
|
111
|
+
return [3, 4];
|
|
112
|
+
case 4: return [2];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}); };
|
|
116
|
+
var handleOnClickLinkedTerminal = function (terminal) {
|
|
117
|
+
dispatch(storeSelectedTerminal(terminal));
|
|
118
|
+
dispatch(handleNextScreenStep(CONNECT_FLOWS.terminal.linkedTerminalInfo));
|
|
119
|
+
};
|
|
120
|
+
var handleOnClickUnlinkedTerminal = function (terminal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
setNewLinkClicked(false);
|
|
125
|
+
dispatch(storeSelectedTerminal(terminal));
|
|
126
|
+
return [4, retrievePOSDevicesAsync(CONNECT_FLOWS.terminal.unlinkedTerminalInfo)];
|
|
127
|
+
case 1:
|
|
128
|
+
_a.sent();
|
|
129
|
+
return [2];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}); };
|
|
133
|
+
var handleOnBack = function () {
|
|
134
|
+
if ((boardFlows === null || boardFlows === void 0 ? void 0 : boardFlows.length) > 0) {
|
|
135
|
+
dispatch(handlePrevScreenStep());
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
var _a = (authData === null || authData === void 0 ? void 0 : authData.recipient) || {}, id = _a.id, type = _a.type;
|
|
139
|
+
var board_id = (boardData || {}).id;
|
|
140
|
+
dispatch(retrieveBoardStatus({ boardId: board_id }))
|
|
141
|
+
.unwrap()
|
|
142
|
+
.then(function () {
|
|
143
|
+
dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type }))
|
|
144
|
+
.unwrap()
|
|
145
|
+
.then(function () {
|
|
146
|
+
dispatch(handlePrevScreenStep());
|
|
147
|
+
});
|
|
148
|
+
})
|
|
149
|
+
.catch(function () { });
|
|
150
|
+
};
|
|
151
|
+
return (_jsxs(ScreenContainer, __assign({ minHeight: 200, justifyContent: 'space-between' }, { children: [_jsxs(Container, __assign({ sx: { pl: 2.5, pr: 2.5 } }, { children: [_jsx(Header, { onLinkClick: handleOnClickNewTerminalLink, loading: posDevicesLoading && newLinkClicked }), _jsx(DeviceList, { devices: linkedDevices, onClick: handleOnClickLinkedTerminal }), !!(unLinkedDevices === null || unLinkedDevices === void 0 ? void 0 : unLinkedDevices.length) && !!(linkedDevices === null || linkedDevices === void 0 ? void 0 : linkedDevices.length) && _jsx(TextTypography, __assign({ sx: { pt: 1, pb: 1 } }, { children: t('terminal_unlinked') })), _jsx(DeviceList, { loading: posDevicesLoading && !newLinkClicked, devices: unLinkedDevices, onClick: handleOnClickUnlinkedTerminal })] })), error && _jsx(Warning, __assign({ sx: { mt: 2 } }, { children: t(error) })), _jsx(Box, __assign({ sx: { pl: 2.5, pr: 2.5 } }, { children: _jsx(Button, __assign({ sx: { mb: 1.5, mt: 1.5 }, onClick: function () { return handleOnBack(); }, variant: 'text' }, { children: loading ? _jsx(Loader, { innerColor: 'black', outerColor: 'black', size: 15, toggleAnimation: !!loading }) : t('back') })) }))] })));
|
|
152
|
+
};
|
|
153
|
+
export default React.memo(TerminalDeviceList);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const DeviceListContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
component?: import("react").ElementType<any> | undefined;
|
|
5
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
6
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
7
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
8
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
9
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | ("left" | "right" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "bottom" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "component" | "ref" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Box from '@mui/material/Box';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
export var DeviceListContainer = styled(Box)(function (_a) {
|
|
4
|
+
var spacing = _a.theme.spacing;
|
|
5
|
+
return ({
|
|
6
|
+
display: 'flex',
|
|
7
|
+
justifyContent: 'space-between',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
width: '100%',
|
|
11
|
+
gap: spacing(0.75)
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import Box from '@mui/material/Box';
|
|
16
|
+
import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
|
|
17
|
+
import { CONNECT_FLOWS } from '../../../../constants';
|
|
18
|
+
import { handleNextScreenStep, handlePrevScreenStep } from '../../../../app/settings';
|
|
19
|
+
import { retrieveBoardDetails, retrieveBoardStatus, retrieveTerminalList, terminalSelector } from '../../../app/terminal/terminalStore';
|
|
20
|
+
import SuccessScreen from '../../../shared/SuccessScreen';
|
|
21
|
+
import Button from '../../../shared/Button';
|
|
22
|
+
import { SuccessContainerStyled } from '../shared';
|
|
23
|
+
var UnlinkedSuccess = function () {
|
|
24
|
+
var t = useTranslation().t;
|
|
25
|
+
var isAr = useLanguage().isAr;
|
|
26
|
+
var dispatch = useAppDispatch();
|
|
27
|
+
var _a = useAppSelector(terminalSelector), error = _a.error, loading = _a.loading, _b = _a.data, device = _b.terminalInfo.selectedTerminal.device, responseData = _b.responseData;
|
|
28
|
+
var _c = responseData || {}, boardData = _c.boardData, authData = _c.authData;
|
|
29
|
+
var deviceName = device === null || device === void 0 ? void 0 : device.display_name;
|
|
30
|
+
var handleGoToBoard = function () {
|
|
31
|
+
var board_id = (boardData || {}).id;
|
|
32
|
+
var _a = (authData === null || authData === void 0 ? void 0 : authData.recipient) || {}, id = _a.id, type = _a.type;
|
|
33
|
+
dispatch(retrieveTerminalList());
|
|
34
|
+
dispatch(retrieveBoardStatus({ boardId: board_id }))
|
|
35
|
+
.unwrap()
|
|
36
|
+
.then(function () {
|
|
37
|
+
dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type }))
|
|
38
|
+
.unwrap()
|
|
39
|
+
.then(function () {
|
|
40
|
+
dispatch(handleNextScreenStep(CONNECT_FLOWS.terminal.board));
|
|
41
|
+
})
|
|
42
|
+
.catch(function () { });
|
|
43
|
+
})
|
|
44
|
+
.catch(function () { });
|
|
45
|
+
};
|
|
46
|
+
var handleOnBack = function () {
|
|
47
|
+
dispatch(handlePrevScreenStep());
|
|
48
|
+
};
|
|
49
|
+
return (_jsxs(SuccessContainerStyled, { children: [_jsx(SuccessScreen, { sx: { minHeight: 'unset', ml: 2.5, mr: 2.5 }, title: t('terminal_unlinked_success', { device: deviceName }), successTitle: t('terminal_go_to_board'), loading: loading, error: error || '' }), _jsx(Box, __assign({ sx: { width: '100%' } }, { children: _jsx(Button, __assign({ loading: loading, disableBack: true, onBackClicked: handleOnBack, onClick: handleGoToBoard, isAr: isAr }, { children: t('terminal_go_to_board') })) }))] }));
|
|
50
|
+
};
|
|
51
|
+
export default React.memo(UnlinkedSuccess);
|
|
@@ -0,0 +1,99 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { useTheme } from '@mui/material/styles';
|
|
16
|
+
import Box from '@mui/material/Box';
|
|
17
|
+
import { CONNECT_FLOWS, DEFAULT_TIMER_VALUE, ICONS_NAMES, TERMINAL_PUSH_NOTIFICATION_DURATION } from '../../../../constants';
|
|
18
|
+
import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
|
|
19
|
+
import { handleNextScreenStep, handlePrevScreenStep } from '../../../../app/settings';
|
|
20
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
21
|
+
import DeviceCard from '../../../../components/DeviceCard';
|
|
22
|
+
import OTPTimer from '../../../../components/OTPTimer';
|
|
23
|
+
import Collapse from '../../../../components/Collapse';
|
|
24
|
+
import { clearError, linkTerminalDevice, pushNotificationLinkNewTerminal, storeSelectedPOS, terminalSelector } from '../../../app/terminal/terminalStore';
|
|
25
|
+
import PushNotification from '../../../shared/PushNotification';
|
|
26
|
+
import Button from '../../../shared/Button';
|
|
27
|
+
import { Container, getId, getIdLabel, LinkWithText } from '../shared';
|
|
28
|
+
import { SendRequestContainer } from './styles';
|
|
29
|
+
import { POSDeviceList } from '../shared';
|
|
30
|
+
var UnlinkedTerminalInfo = function () {
|
|
31
|
+
var t = useTranslation().t;
|
|
32
|
+
var typography = useTheme().typography;
|
|
33
|
+
var dispatch = useAppDispatch();
|
|
34
|
+
var isAr = useLanguage().isAr;
|
|
35
|
+
var _a = React.useState(false), isRequestSent = _a[0], setIsRequestSent = _a[1];
|
|
36
|
+
var _b = React.useState(false), isReady = _b[0], setIsReady = _b[1];
|
|
37
|
+
var _c = React.useState(false), success = _c[0], setSuccess = _c[1];
|
|
38
|
+
var _d = React.useState(false), failed = _d[0], setFailed = _d[1];
|
|
39
|
+
var _e = useAppSelector(terminalSelector), data = _e.data, error = _e.error;
|
|
40
|
+
var _f = data.terminalInfo, selectedTerminal = _f.selectedTerminal, selectedPOS = _f.selectedPOS, responseData = data.responseData;
|
|
41
|
+
var _g = responseData || {}, linkTerminalDeviceData = _g.linkTerminalDeviceData, posDevices = _g.posDevices;
|
|
42
|
+
var terminal_device = selectedTerminal.terminal_device, linked = selectedTerminal.linked;
|
|
43
|
+
var _h = ((terminal_device === null || terminal_device === void 0 ? void 0 : terminal_device.model) || {}).image_url, image_url = _h === void 0 ? ICONS_NAMES.device_image : _h;
|
|
44
|
+
var displayName = (terminal_device === null || terminal_device === void 0 ? void 0 : terminal_device.display_name) || '';
|
|
45
|
+
var expiry = TERMINAL_PUSH_NOTIFICATION_DURATION;
|
|
46
|
+
var newTerminal = false;
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
if (linkTerminalDeviceData && !isReady) {
|
|
49
|
+
setIsReady(true);
|
|
50
|
+
}
|
|
51
|
+
}, [linkTerminalDeviceData]);
|
|
52
|
+
React.useEffect(function () {
|
|
53
|
+
if (!isReady)
|
|
54
|
+
return;
|
|
55
|
+
var promise = dispatch(pushNotificationLinkNewTerminal({ newTerminal: newTerminal, onSuccess: function () { return setSuccess(true); }, onFailure: function () { return setFailed(true); } }));
|
|
56
|
+
promise
|
|
57
|
+
.unwrap()
|
|
58
|
+
.then(function (_a) {
|
|
59
|
+
var nextScreen = _a.nextScreen;
|
|
60
|
+
if (nextScreen)
|
|
61
|
+
dispatch(handleNextScreenStep(nextScreen));
|
|
62
|
+
})
|
|
63
|
+
.catch(function () { });
|
|
64
|
+
return function () {
|
|
65
|
+
promise === null || promise === void 0 ? void 0 : promise.abort();
|
|
66
|
+
};
|
|
67
|
+
}, [isReady]);
|
|
68
|
+
var getRequestSendDescription = function () {
|
|
69
|
+
if (error)
|
|
70
|
+
return t('terminal_request_denied', { device: displayName });
|
|
71
|
+
if (isRequestSent)
|
|
72
|
+
return t('terminal_new_request_will_send');
|
|
73
|
+
return t('terminal_request_will_send');
|
|
74
|
+
};
|
|
75
|
+
var handleOnSendRequest = function () {
|
|
76
|
+
setIsRequestSent(true);
|
|
77
|
+
handleOnResendClick();
|
|
78
|
+
};
|
|
79
|
+
var handleOnBack = function () {
|
|
80
|
+
if (error)
|
|
81
|
+
dispatch(clearError());
|
|
82
|
+
dispatch(handlePrevScreenStep(CONNECT_FLOWS.terminal.terminalDeviceList));
|
|
83
|
+
};
|
|
84
|
+
var handleOnSelectPOS = function (pos) {
|
|
85
|
+
if (error)
|
|
86
|
+
dispatch(clearError());
|
|
87
|
+
dispatch(storeSelectedPOS(pos));
|
|
88
|
+
};
|
|
89
|
+
var handleOnResendClick = function () {
|
|
90
|
+
if (isReady)
|
|
91
|
+
setIsReady(false);
|
|
92
|
+
if (failed)
|
|
93
|
+
setFailed(false);
|
|
94
|
+
dispatch(linkTerminalDevice());
|
|
95
|
+
};
|
|
96
|
+
var disabled = !(selectedPOS === null || selectedPOS === void 0 ? void 0 : selectedPOS.id) || isRequestSent;
|
|
97
|
+
return (_jsxs(ScreenContainer, __assign({ minHeight: 224, justifyContent: 'space-between' }, { children: [_jsx(PushNotification, __assign({ error: t('terminal_request_denied', { device: displayName }), failed: failed, success: success, expiryInSeconds: expiry }, { children: _jsxs(Container, { children: [_jsxs(Box, __assign({ sx: { ml: 2.5, mr: 2.5 } }, { children: [_jsx(LinkWithText, { children: "".concat(t('terminal_link'), " ").concat(displayName) }), _jsx(DeviceCard, { image: image_url, name: displayName, deviceId: getId(selectedTerminal), deviceIdLabel: getIdLabel(selectedTerminal), isLinked: linked }), _jsx(LinkWithText, { children: t('terminal_with') }), _jsx(POSDeviceList, { selectedPOS: selectedPOS, posDevices: posDevices, onClick: handleOnSelectPOS })] })), _jsxs(SendRequestContainer, __assign({ hasError: !!error, sx: __assign(__assign({}, typography.button_small), { fontWeight: typography.fontWeightRegular, mt: 2 }) }, { children: [getRequestSendDescription(), _jsx(Collapse, __assign({ in: isRequestSent && !error }, { children: _jsx(OTPTimer, { timeEndLabel: t('terminal_resend_request'), failed: failed, timeInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendClick }) }))] }))] }) })), _jsx(Button, __assign({ sx: { ml: 2.5, mr: 2.5, mt: 2 }, disabled: disabled, onBackClicked: handleOnBack, onClick: handleOnSendRequest, isAr: isAr }, { children: t('terminal_send_link_request') }))] })));
|
|
98
|
+
};
|
|
99
|
+
export default React.memo(UnlinkedTerminalInfo);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ResendText: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
3
|
+
align?: "left" | "right" | "inherit" | "center" | "justify" | undefined;
|
|
4
|
+
children?: import("react").ReactNode;
|
|
5
|
+
classes?: Partial<import("@mui/material/Typography").TypographyClasses> | undefined;
|
|
6
|
+
gutterBottom?: boolean | undefined;
|
|
7
|
+
noWrap?: boolean | undefined;
|
|
8
|
+
paragraph?: boolean | undefined;
|
|
9
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
10
|
+
variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | undefined;
|
|
11
|
+
variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline", string>> | undefined;
|
|
12
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof import("react").HTMLAttributes<HTMLSpanElement>> & {
|
|
13
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
14
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | ("left" | "right" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "bottom" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "sx" | "variant" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
15
|
+
interface SendRequestContainerProps {
|
|
16
|
+
hasError?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const SendRequestContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
19
|
+
children?: import("react").ReactNode;
|
|
20
|
+
component?: import("react").ElementType<any> | undefined;
|
|
21
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
22
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
23
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
24
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
25
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | ("left" | "right" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "bottom" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "component" | "ref" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & SendRequestContainerProps, {}, {}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { alpha, styled } from '@mui/material/styles';
|
|
13
|
+
import Typography from '@mui/material/Typography';
|
|
14
|
+
import Box from '@mui/material/Box';
|
|
15
|
+
export var ResendText = styled(Typography)(function (_a) {
|
|
16
|
+
var _b = _a.theme, palette = _b.palette, typography = _b.typography, spacing = _b.spacing;
|
|
17
|
+
return (__assign(__assign({ cursor: 'pointer', color: palette.primary.main }, typography.caption), { fontWeight: typography.fontWeightRegular, textAlign: 'end', marginTop: spacing(0.75) }));
|
|
18
|
+
});
|
|
19
|
+
export var SendRequestContainer = styled(Box, {
|
|
20
|
+
shouldForwardProp: function (prop) { return !['hasError'].includes(prop.toString()); }
|
|
21
|
+
})(function (_a) {
|
|
22
|
+
var _b = _a.theme, typography = _b.typography, palette = _b.palette, spacing = _b.spacing, hasError = _a.hasError;
|
|
23
|
+
return (__assign(__assign(__assign(__assign({}, typography.button_small), { fontWeight: typography.fontWeightRegular, mt: 2, backgroundColor: palette.common.white, borderWidth: spacing(0.125, 0, 0.125, 0), borderStyle: 'solid', borderColor: palette.divider, padding: spacing(1.5, 2.5, 1.5, 2.5), marginTop: spacing(1), color: palette.text.primary }), typography.body1), (hasError && {
|
|
24
|
+
background: alpha(palette.error.dark, 0.3),
|
|
25
|
+
borderWidth: '1px, 0px, 1px, 0px',
|
|
26
|
+
borderStyle: 'solid',
|
|
27
|
+
borderColor: alpha(palette.error.dark, 0.7),
|
|
28
|
+
color: alpha(palette.error.main, 0.7)
|
|
29
|
+
})));
|
|
30
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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 * as React from 'react';
|
|
14
|
+
import Box from '@mui/material/Box/Box';
|
|
15
|
+
import { styled } from '@mui/material/styles';
|
|
16
|
+
import OTPField from '../../../shared/OTP';
|
|
17
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
18
|
+
import { useTranslation } from 'react-i18next';
|
|
19
|
+
import { DEFAULT_TIMER_VALUE } from '../../../../constants';
|
|
20
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
21
|
+
import { isTokenExpired } from '../../../../utils';
|
|
22
|
+
import { clearError, terminalSelector, resendOTP } from '../../../app/terminal/terminalStore';
|
|
23
|
+
var BoxStyled = styled(Box)(function (_a) {
|
|
24
|
+
var theme = _a.theme;
|
|
25
|
+
return ({
|
|
26
|
+
display: 'flex',
|
|
27
|
+
flexDirection: 'column',
|
|
28
|
+
fontFamily: theme.typography.fontFamily
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
var OTPInput = function (_a) {
|
|
32
|
+
var loading = _a.loading;
|
|
33
|
+
var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
|
|
34
|
+
var t = useTranslation().t;
|
|
35
|
+
var otpControl = useController({ name: 'otp', control: control });
|
|
36
|
+
var dispatch = useAppDispatch();
|
|
37
|
+
var error = useAppSelector(terminalSelector).error;
|
|
38
|
+
var handleOnOTPChange = function (otp) {
|
|
39
|
+
if (error)
|
|
40
|
+
dispatch(clearError());
|
|
41
|
+
otpControl.field.onChange(otp);
|
|
42
|
+
};
|
|
43
|
+
var handleOnResendOTP = function () {
|
|
44
|
+
if (otpControl.field.value)
|
|
45
|
+
setValue('otp', '', { shouldValidate: true });
|
|
46
|
+
dispatch(resendOTP());
|
|
47
|
+
};
|
|
48
|
+
var otpValue = otpControl.field.value;
|
|
49
|
+
return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { loading: loading, timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, hasError: isTokenExpired(error), onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
|
|
50
|
+
};
|
|
51
|
+
export default React.memo(OTPInput);
|
|
@@ -0,0 +1,89 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useAppDispatch, useSetFromDefaultValues, useSanitizedTranslation, useLanguage, useAppSelector } from '../../../../hooks';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { useForm, FormProvider } from 'react-hook-form';
|
|
17
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
18
|
+
import Box from '@mui/material/Box/Box';
|
|
19
|
+
import { styled } from '@mui/material/styles';
|
|
20
|
+
import { handleNextScreenStep } from '../../../../app/settings';
|
|
21
|
+
import { deepCopy, isAuthenticationVerificationFailed, maskPhone } from '../../../../utils';
|
|
22
|
+
import Form from '../../../../components/Form';
|
|
23
|
+
import Text from '../../../../components/Text';
|
|
24
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
25
|
+
import { terminalSelector, clearError, resetOTPScreen, verifyTokenOTP } from '../../../app/terminal/terminalStore';
|
|
26
|
+
import Button from '../../../shared/Button';
|
|
27
|
+
import { OTPValidation } from './validation';
|
|
28
|
+
import OTPInput from './OTPInput';
|
|
29
|
+
import { CONNECT_FLOWS } from '../../../../constants';
|
|
30
|
+
var OTPTitleContainerStyled = styled(Box)(function (_a) {
|
|
31
|
+
var theme = _a.theme;
|
|
32
|
+
return ({
|
|
33
|
+
background: theme.palette.common.white,
|
|
34
|
+
border: '1px solid',
|
|
35
|
+
borderColor: theme.palette.divider,
|
|
36
|
+
direction: theme.direction,
|
|
37
|
+
borderRadius: theme.spacing(0, 0, 1.25, 1.25),
|
|
38
|
+
marginBottom: theme.spacing(5.75)
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
var OTPTitleStyled = styled(Text)(function (_a) {
|
|
42
|
+
var theme = _a.theme;
|
|
43
|
+
return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.75 }));
|
|
44
|
+
});
|
|
45
|
+
var FormStyled = styled(Form)(function () { return ({
|
|
46
|
+
display: 'flex',
|
|
47
|
+
flexDirection: 'column'
|
|
48
|
+
}); });
|
|
49
|
+
var VerifyNumber = function (_a) {
|
|
50
|
+
var _b, _c, _d;
|
|
51
|
+
var dispatch = useAppDispatch();
|
|
52
|
+
var _e = useAppSelector(terminalSelector), data = _e.data, loading = _e.loading, error = _e.error;
|
|
53
|
+
var otp = data.otpData.otp;
|
|
54
|
+
var methods = useForm({
|
|
55
|
+
resolver: yupResolver(OTPValidation),
|
|
56
|
+
defaultValues: {
|
|
57
|
+
otp: otp
|
|
58
|
+
},
|
|
59
|
+
mode: 'onChange'
|
|
60
|
+
});
|
|
61
|
+
useSetFromDefaultValues(methods, data.otpData);
|
|
62
|
+
var t = useTranslation().t;
|
|
63
|
+
var st = useSanitizedTranslation();
|
|
64
|
+
var isAr = useLanguage().isAr;
|
|
65
|
+
var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
|
|
66
|
+
var phone = (_d = (_c = (_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authData) === null || _c === void 0 ? void 0 : _c.verification_by) === null || _d === void 0 ? void 0 : _d.sent_to;
|
|
67
|
+
React.useEffect(function () {
|
|
68
|
+
if (error && methods.formState.isValid && phone)
|
|
69
|
+
dispatch(clearError());
|
|
70
|
+
return function () {
|
|
71
|
+
dispatch(resetOTPScreen());
|
|
72
|
+
};
|
|
73
|
+
}, [methods.formState.isValid]);
|
|
74
|
+
var onSubmit = function (formData) {
|
|
75
|
+
dispatch(verifyTokenOTP(deepCopy(formData)))
|
|
76
|
+
.unwrap()
|
|
77
|
+
.then(function (_a) {
|
|
78
|
+
var nextScreen = _a.nextScreen;
|
|
79
|
+
dispatch(handleNextScreenStep(nextScreen));
|
|
80
|
+
})
|
|
81
|
+
.catch(function (err) {
|
|
82
|
+
if (isAuthenticationVerificationFailed(err === null || err === void 0 ? void 0 : err.message))
|
|
83
|
+
dispatch(handleNextScreenStep(CONNECT_FLOWS.terminal.otpVerifySecurityError));
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
var disabled = !methods.formState.isValid || !phone || resendLoading;
|
|
87
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? st('ide_otp_waiting_title') : st('ide_opt_sent_title'), !loading && phone && _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone || '')) }))] }) }), _jsx(OTPInput, { loading: resendLoading, setLoading: setResendLoading }), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
|
|
88
|
+
};
|
|
89
|
+
export default React.memo(VerifyNumber);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
5
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
6
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
|
+
}>>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material';
|
|
3
|
+
interface HeaderProps {
|
|
4
|
+
onLinkClick?: () => void;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
title?: string;
|
|
7
|
+
sx?: SxProps<Theme>;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: React.MemoExoticComponent<({ onLinkClick, loading, title, sx }: HeaderProps) => JSX.Element>;
|
|
10
|
+
export default _default;
|