ordering-components-external 13.1.6 → 13.1.8
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/_bundles/{7.ordering-component.df125e6026f88a037006.js → 7.ordering-component.94a28b3a5bfb4d729a1b.js} +1 -1
- package/_bundles/ordering-component.94a28b3a5bfb4d729a1b.js +2 -0
- package/_modules/components/BusinessAndProductList/index.js +1 -0
- package/_modules/components/LogoutAction/index.js +84 -10
- package/package.json +1 -1
- package/src/components/BusinessAndProductList/index.js +1 -0
- package/src/components/LogoutAction/index.js +48 -2
- package/_bundles/ordering-component.df125e6026f88a037006.js +0 -2
- /package/_bundles/{0.ordering-component.df125e6026f88a037006.js → 0.ordering-component.94a28b3a5bfb4d729a1b.js} +0 -0
- /package/_bundles/{1.ordering-component.df125e6026f88a037006.js → 1.ordering-component.94a28b3a5bfb4d729a1b.js} +0 -0
- /package/_bundles/{2.ordering-component.df125e6026f88a037006.js → 2.ordering-component.94a28b3a5bfb4d729a1b.js} +0 -0
- /package/_bundles/{4.ordering-component.df125e6026f88a037006.js → 4.ordering-component.94a28b3a5bfb4d729a1b.js} +0 -0
- /package/_bundles/{5.ordering-component.df125e6026f88a037006.js → 5.ordering-component.94a28b3a5bfb4d729a1b.js} +0 -0
- /package/_bundles/{6.ordering-component.df125e6026f88a037006.js → 6.ordering-component.94a28b3a5bfb4d729a1b.js} +0 -0
- /package/_bundles/{7.ordering-component.df125e6026f88a037006.js.LICENSE.txt → 7.ordering-component.94a28b3a5bfb4d729a1b.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-component.df125e6026f88a037006.js → 8.ordering-component.94a28b3a5bfb4d729a1b.js} +0 -0
- /package/_bundles/{ordering-component.df125e6026f88a037006.js.LICENSE.txt → ordering-component.94a28b3a5bfb4d729a1b.js.LICENSE.txt} +0 -0
|
@@ -917,6 +917,7 @@ var BusinessAndProductList = exports.BusinessAndProductList = function BusinessA
|
|
|
917
917
|
source = {};
|
|
918
918
|
requestsState.business = source;
|
|
919
919
|
parameters = {
|
|
920
|
+
version: 'v2',
|
|
920
921
|
type: ((_orderState$options10 = orderState.options) === null || _orderState$options10 === void 0 ? void 0 : _orderState$options10.type) || 1,
|
|
921
922
|
location: location ? "".concat(location === null || location === void 0 ? void 0 : location.lat, ",").concat(location === null || location === void 0 ? void 0 : location.lng) : (_orderState$options11 = orderState.options) !== null && _orderState$options11 !== void 0 && (_orderState$options11 = _orderState$options11.address) !== null && _orderState$options11 !== void 0 && _orderState$options11.location ? "".concat((_orderState$options12 = orderState.options) === null || _orderState$options12 === void 0 || (_orderState$options12 = _orderState$options12.address) === null || _orderState$options12 === void 0 || (_orderState$options12 = _orderState$options12.location) === null || _orderState$options12 === void 0 ? void 0 : _orderState$options12.lat, ",").concat((_orderState$options13 = orderState.options) === null || _orderState$options13 === void 0 || (_orderState$options13 = _orderState$options13.address) === null || _orderState$options13 === void 0 || (_orderState$options13 = _orderState$options13.location) === null || _orderState$options13 === void 0 ? void 0 : _orderState$options13.lng) : null
|
|
922
923
|
};
|
|
@@ -10,6 +10,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
10
10
|
var _SessionContext = require("../../contexts/SessionContext");
|
|
11
11
|
var _ApiContext = require("../../contexts/ApiContext");
|
|
12
12
|
var _ConfigContext = require("../../contexts/ConfigContext");
|
|
13
|
+
var _LanguageContext = require("../../contexts/LanguageContext");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -38,10 +39,14 @@ var LogoutAction = exports.LogoutAction = function LogoutAction(props) {
|
|
|
38
39
|
token = props.token,
|
|
39
40
|
isNative = props.isNative,
|
|
40
41
|
useDefualtSessionManager = props.useDefualtSessionManager,
|
|
41
|
-
handleCustomLogoutClick = props.handleCustomLogoutClick
|
|
42
|
+
handleCustomLogoutClick = props.handleCustomLogoutClick,
|
|
43
|
+
isDriverApp = props.isDriverApp;
|
|
42
44
|
var _useApi = (0, _ApiContext.useApi)(),
|
|
43
45
|
_useApi2 = _slicedToArray(_useApi, 1),
|
|
44
46
|
ordering = _useApi2[0];
|
|
47
|
+
var _useLanguage = (0, _LanguageContext.useLanguage)(),
|
|
48
|
+
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
49
|
+
t = _useLanguage2[1];
|
|
45
50
|
var _useState = (0, _react.useState)({
|
|
46
51
|
loading: false,
|
|
47
52
|
result: {
|
|
@@ -109,7 +114,7 @@ var LogoutAction = exports.LogoutAction = function LogoutAction(props) {
|
|
|
109
114
|
*/
|
|
110
115
|
var handleLogoutClick = /*#__PURE__*/function () {
|
|
111
116
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(bodyParams) {
|
|
112
|
-
var accessToken, body, funtionFetch, _yield$funtionFetch, _yield$funtionFetch$c, error, result;
|
|
117
|
+
var _response$content, _response$content2, response, _response$content3, _response$content4, accessToken, body, funtionFetch, _yield$funtionFetch, _yield$funtionFetch$c, error, result;
|
|
113
118
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
114
119
|
while (1) switch (_context.prev = _context.next) {
|
|
115
120
|
case 0:
|
|
@@ -120,6 +125,27 @@ var LogoutAction = exports.LogoutAction = function LogoutAction(props) {
|
|
|
120
125
|
setFormState(_objectSpread(_objectSpread({}, formState), {}, {
|
|
121
126
|
loading: true
|
|
122
127
|
}));
|
|
128
|
+
if (!isDriverApp) {
|
|
129
|
+
_context.next = 10;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
_context.next = 6;
|
|
133
|
+
return getActiveOrders();
|
|
134
|
+
case 6:
|
|
135
|
+
response = _context.sent;
|
|
136
|
+
if (!(response !== null && response !== void 0 && (_response$content = response.content) !== null && _response$content !== void 0 && _response$content.error || response !== null && response !== void 0 && (_response$content2 = response.content) !== null && _response$content2 !== void 0 && (_response$content2 = _response$content2.result) !== null && _response$content2 !== void 0 && (_response$content2 = _response$content2[0]) !== null && _response$content2 !== void 0 && _response$content2.id)) {
|
|
137
|
+
_context.next = 10;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
setFormState({
|
|
141
|
+
result: {
|
|
142
|
+
error: true,
|
|
143
|
+
result: response !== null && response !== void 0 && (_response$content3 = response.content) !== null && _response$content3 !== void 0 && _response$content3.error ? response === null || response === void 0 || (_response$content4 = response.content) === null || _response$content4 === void 0 ? void 0 : _response$content4.result : t('ERROR_USER_LOGOUT_YOU_HAVE_ASSIGNED_ORDERS', 'Can\'t logout, You have assigned orders')
|
|
144
|
+
},
|
|
145
|
+
loading: false
|
|
146
|
+
});
|
|
147
|
+
return _context.abrupt("return");
|
|
148
|
+
case 10:
|
|
123
149
|
accessToken = token || data.token;
|
|
124
150
|
body = bodyParams && bodyParams !== null && bodyParams !== void 0 && bodyParams.notification_token ? {
|
|
125
151
|
notification_app: bodyParams === null || bodyParams === void 0 ? void 0 : bodyParams.notification_app,
|
|
@@ -127,15 +153,15 @@ var LogoutAction = exports.LogoutAction = function LogoutAction(props) {
|
|
|
127
153
|
token_notification: bodyParams === null || bodyParams === void 0 ? void 0 : bodyParams.notification_token
|
|
128
154
|
} : null;
|
|
129
155
|
funtionFetch = body ? ordering.setAccessToken(accessToken).users().logout(body) : ordering.setAccessToken(accessToken).users().logout();
|
|
130
|
-
_context.next =
|
|
156
|
+
_context.next = 15;
|
|
131
157
|
return funtionFetch;
|
|
132
|
-
case
|
|
158
|
+
case 15:
|
|
133
159
|
_yield$funtionFetch = _context.sent;
|
|
134
160
|
_yield$funtionFetch$c = _yield$funtionFetch.content;
|
|
135
161
|
error = _yield$funtionFetch$c.error;
|
|
136
162
|
result = _yield$funtionFetch$c.result;
|
|
137
163
|
if (error) {
|
|
138
|
-
_context.next =
|
|
164
|
+
_context.next = 24;
|
|
139
165
|
break;
|
|
140
166
|
}
|
|
141
167
|
setFormState({
|
|
@@ -152,7 +178,7 @@ var LogoutAction = exports.LogoutAction = function LogoutAction(props) {
|
|
|
152
178
|
handleSuccessLogout();
|
|
153
179
|
}
|
|
154
180
|
return _context.abrupt("return", true);
|
|
155
|
-
case
|
|
181
|
+
case 24:
|
|
156
182
|
setFormState({
|
|
157
183
|
result: {
|
|
158
184
|
error: error,
|
|
@@ -161,8 +187,8 @@ var LogoutAction = exports.LogoutAction = function LogoutAction(props) {
|
|
|
161
187
|
loading: false
|
|
162
188
|
});
|
|
163
189
|
return _context.abrupt("return", false);
|
|
164
|
-
case
|
|
165
|
-
_context.prev =
|
|
190
|
+
case 28:
|
|
191
|
+
_context.prev = 28;
|
|
166
192
|
_context.t0 = _context["catch"](1);
|
|
167
193
|
setFormState({
|
|
168
194
|
result: {
|
|
@@ -172,16 +198,64 @@ var LogoutAction = exports.LogoutAction = function LogoutAction(props) {
|
|
|
172
198
|
loading: false
|
|
173
199
|
});
|
|
174
200
|
return _context.abrupt("return", false);
|
|
175
|
-
case
|
|
201
|
+
case 32:
|
|
176
202
|
case "end":
|
|
177
203
|
return _context.stop();
|
|
178
204
|
}
|
|
179
|
-
}, _callee, null, [[1,
|
|
205
|
+
}, _callee, null, [[1, 28]]);
|
|
180
206
|
}));
|
|
181
207
|
return function handleLogoutClick(_x) {
|
|
182
208
|
return _ref.apply(this, arguments);
|
|
183
209
|
};
|
|
184
210
|
}();
|
|
211
|
+
var getActiveOrders = /*#__PURE__*/function () {
|
|
212
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
213
|
+
var options, accessToken, orderStatus, propsToFetch, functionFetch;
|
|
214
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
215
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
216
|
+
case 0:
|
|
217
|
+
_context2.prev = 0;
|
|
218
|
+
options = {
|
|
219
|
+
query: {
|
|
220
|
+
page: 1,
|
|
221
|
+
page_size: 1
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
accessToken = token || data.token;
|
|
225
|
+
orderStatus = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23, 24, 25, 26];
|
|
226
|
+
options.query.where = [];
|
|
227
|
+
if (orderStatus) {
|
|
228
|
+
options.query.where.push({
|
|
229
|
+
attribute: 'status',
|
|
230
|
+
value: orderStatus
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
propsToFetch = ['id', 'status'];
|
|
234
|
+
functionFetch = ordering.setAccessToken(accessToken).orders().asDashboard().select(propsToFetch);
|
|
235
|
+
_context2.next = 10;
|
|
236
|
+
return functionFetch.get(options);
|
|
237
|
+
case 10:
|
|
238
|
+
return _context2.abrupt("return", _context2.sent);
|
|
239
|
+
case 13:
|
|
240
|
+
_context2.prev = 13;
|
|
241
|
+
_context2.t0 = _context2["catch"](0);
|
|
242
|
+
setFormState({
|
|
243
|
+
result: {
|
|
244
|
+
error: true,
|
|
245
|
+
result: _context2.t0.message
|
|
246
|
+
},
|
|
247
|
+
loading: false
|
|
248
|
+
});
|
|
249
|
+
case 16:
|
|
250
|
+
case "end":
|
|
251
|
+
return _context2.stop();
|
|
252
|
+
}
|
|
253
|
+
}, _callee2, null, [[0, 13]]);
|
|
254
|
+
}));
|
|
255
|
+
return function getActiveOrders() {
|
|
256
|
+
return _ref2.apply(this, arguments);
|
|
257
|
+
};
|
|
258
|
+
}();
|
|
185
259
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, UIComponent && /*#__PURE__*/_react.default.createElement(UIComponent, _extends({}, props, {
|
|
186
260
|
formState: formState,
|
|
187
261
|
handleLogoutClick: handleLogoutClick
|
package/package.json
CHANGED
|
@@ -698,6 +698,7 @@ export const BusinessAndProductList = (props) => {
|
|
|
698
698
|
const source = {}
|
|
699
699
|
requestsState.business = source
|
|
700
700
|
const parameters = {
|
|
701
|
+
version: 'v2',
|
|
701
702
|
type: orderState.options?.type || 1,
|
|
702
703
|
location: location
|
|
703
704
|
? `${location?.lat},${location?.lng}`
|
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import { useSession } from '../../contexts/SessionContext'
|
|
4
4
|
import { useApi } from '../../contexts/ApiContext'
|
|
5
5
|
import { useConfig } from '../../contexts/ConfigContext'
|
|
6
|
+
import { useLanguage } from '../../contexts/LanguageContext'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Component to manage logout behavior without UI component
|
|
@@ -14,10 +15,12 @@ export const LogoutAction = (props) => {
|
|
|
14
15
|
token,
|
|
15
16
|
isNative,
|
|
16
17
|
useDefualtSessionManager,
|
|
17
|
-
handleCustomLogoutClick
|
|
18
|
+
handleCustomLogoutClick,
|
|
19
|
+
isDriverApp
|
|
18
20
|
} = props
|
|
19
21
|
|
|
20
22
|
const [ordering] = useApi()
|
|
23
|
+
const [, t] = useLanguage()
|
|
21
24
|
const [formState, setFormState] = useState({ loading: false, result: { error: false } })
|
|
22
25
|
|
|
23
26
|
const [data, { logout }] = useSession()
|
|
@@ -79,11 +82,26 @@ export const LogoutAction = (props) => {
|
|
|
79
82
|
}
|
|
80
83
|
try {
|
|
81
84
|
setFormState({ ...formState, loading: true })
|
|
85
|
+
if (isDriverApp) {
|
|
86
|
+
const response = await getActiveOrders()
|
|
87
|
+
if (response?.content?.error || response?.content?.result?.[0]?.id) {
|
|
88
|
+
setFormState({
|
|
89
|
+
result: {
|
|
90
|
+
error: true,
|
|
91
|
+
result: response?.content?.error
|
|
92
|
+
? response?.content?.result
|
|
93
|
+
: t('ERROR_USER_LOGOUT_YOU_HAVE_ASSIGNED_ORDERS', 'Can\'t logout, You have assigned orders')
|
|
94
|
+
},
|
|
95
|
+
loading: false
|
|
96
|
+
})
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
}
|
|
82
100
|
const accessToken = token || data.token
|
|
83
101
|
const body = bodyParams && bodyParams?.notification_token ? {
|
|
84
102
|
notification_app: bodyParams?.notification_app,
|
|
85
103
|
notification_token: bodyParams?.notification_token,
|
|
86
|
-
token_notification: bodyParams?.notification_token
|
|
104
|
+
token_notification: bodyParams?.notification_token
|
|
87
105
|
} : null
|
|
88
106
|
const funtionFetch = body
|
|
89
107
|
? ordering.setAccessToken(accessToken).users().logout(body)
|
|
@@ -119,6 +137,34 @@ export const LogoutAction = (props) => {
|
|
|
119
137
|
}
|
|
120
138
|
}
|
|
121
139
|
|
|
140
|
+
const getActiveOrders = async () => {
|
|
141
|
+
try {
|
|
142
|
+
const options = {
|
|
143
|
+
query: {
|
|
144
|
+
page: 1,
|
|
145
|
+
page_size: 1
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const accessToken = token || data.token
|
|
149
|
+
const orderStatus = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23, 24, 25, 26]
|
|
150
|
+
options.query.where = []
|
|
151
|
+
if (orderStatus) {
|
|
152
|
+
options.query.where.push({ attribute: 'status', value: orderStatus })
|
|
153
|
+
}
|
|
154
|
+
const propsToFetch = ['id', 'status']
|
|
155
|
+
const functionFetch = ordering.setAccessToken(accessToken).orders().asDashboard().select(propsToFetch)
|
|
156
|
+
return await functionFetch.get(options)
|
|
157
|
+
} catch (err) {
|
|
158
|
+
setFormState({
|
|
159
|
+
result: {
|
|
160
|
+
error: true,
|
|
161
|
+
result: err.message
|
|
162
|
+
},
|
|
163
|
+
loading: false
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
122
168
|
return (
|
|
123
169
|
<>
|
|
124
170
|
{UIComponent && (
|