akeyless-client-commons 1.1.70 → 1.1.71
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/dist/components/index.css.map +1 -1
- package/dist/components/index.js +105 -155
- package/dist/components/index.mjs +74 -124
- package/dist/helpers/index.js +191 -249
- package/dist/helpers/index.mjs +140 -198
- package/dist/hooks/index.js +40 -90
- package/dist/hooks/index.mjs +9 -59
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -583,7 +583,7 @@ var import_app = require("firebase/app");
|
|
|
583
583
|
var import_storage = require("firebase/storage");
|
|
584
584
|
var import_auth = require("firebase/auth");
|
|
585
585
|
var import_app_check = require("firebase/app-check");
|
|
586
|
-
var
|
|
586
|
+
var import_firestore2 = require("firebase/firestore");
|
|
587
587
|
var import_react = require("react");
|
|
588
588
|
// src/helpers/phoneNumber.ts
|
|
589
589
|
var import_libphonenumber_js = require("libphonenumber-js");
|
|
@@ -632,6 +632,75 @@ var parsePermissions = function(object) {
|
|
|
632
632
|
};
|
|
633
633
|
// src/helpers/firebase.ts
|
|
634
634
|
var import_storage2 = require("firebase/storage");
|
|
635
|
+
// src/helpers/time_helpers.ts
|
|
636
|
+
var import_firestore = require("firebase/firestore");
|
|
637
|
+
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
638
|
+
function timestamp_to_string(firebaseTimestamp, options) {
|
|
639
|
+
var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
|
|
640
|
+
var _ref = {
|
|
641
|
+
defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
|
|
642
|
+
format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
|
|
643
|
+
fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
|
|
644
|
+
tz: options === null || options === void 0 ? void 0 : options.tz,
|
|
645
|
+
debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
|
|
646
|
+
}, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
|
|
647
|
+
var date;
|
|
648
|
+
switch(true){
|
|
649
|
+
case !firebaseTimestamp:
|
|
650
|
+
{
|
|
651
|
+
return defaultReturnedValue;
|
|
652
|
+
}
|
|
653
|
+
case _instanceof(firebaseTimestamp, import_firestore.Timestamp):
|
|
654
|
+
{
|
|
655
|
+
date = firebaseTimestamp.toDate();
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
case _instanceof(firebaseTimestamp, Date):
|
|
659
|
+
{
|
|
660
|
+
date = firebaseTimestamp;
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
case typeof firebaseTimestamp === "string":
|
|
664
|
+
{
|
|
665
|
+
var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
|
|
666
|
+
switch(m.isValid()){
|
|
667
|
+
case true:
|
|
668
|
+
date = m.toDate();
|
|
669
|
+
break;
|
|
670
|
+
default:
|
|
671
|
+
return defaultReturnedValue;
|
|
672
|
+
}
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
case !!firebaseTimestamp._seconds:
|
|
676
|
+
{
|
|
677
|
+
var ft = firebaseTimestamp;
|
|
678
|
+
var _ft__nanoseconds;
|
|
679
|
+
date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
case !!firebaseTimestamp.seconds:
|
|
683
|
+
{
|
|
684
|
+
var ft1 = firebaseTimestamp;
|
|
685
|
+
date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
default:
|
|
689
|
+
{
|
|
690
|
+
if (debug) {
|
|
691
|
+
console.error("Invalid timestamp format: ", firebaseTimestamp);
|
|
692
|
+
}
|
|
693
|
+
return defaultReturnedValue;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
switch(Boolean(tz)){
|
|
697
|
+
case true:
|
|
698
|
+
return (0, import_moment_timezone.default)(date).tz(tz).format(format);
|
|
699
|
+
default:
|
|
700
|
+
return import_moment_timezone.default.utc(date).format(format);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
// src/helpers/firebase.ts
|
|
635
704
|
var import_meta = {};
|
|
636
705
|
var initApp = function() {
|
|
637
706
|
var isNodeEnv2 = typeof process !== "undefined" && process.env;
|
|
@@ -647,7 +716,7 @@ var initApp = function() {
|
|
|
647
716
|
var app2 = (0, import_app.initializeApp)(firebaseConfig);
|
|
648
717
|
var auth2 = (0, import_auth.getAuth)(app2);
|
|
649
718
|
auth2.settings.appVerificationDisabledForTesting = false;
|
|
650
|
-
var db2 = (0,
|
|
719
|
+
var db2 = (0, import_firestore2.getFirestore)(app2);
|
|
651
720
|
var storage2 = (0, import_storage.getStorage)(app2);
|
|
652
721
|
var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
|
|
653
722
|
var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta.env.VITE_RECAPTCHA_SITE_KEY;
|
|
@@ -697,33 +766,33 @@ var useLoginWithGoogle = function() {
|
|
|
697
766
|
return signInWithGoogle;
|
|
698
767
|
};
|
|
699
768
|
var collections = {
|
|
700
|
-
clients: (0,
|
|
701
|
-
sites: (0,
|
|
702
|
-
cars: (0,
|
|
703
|
-
users: (0,
|
|
704
|
-
lastLocations: (0,
|
|
705
|
-
ermEvents: (0,
|
|
706
|
-
erm2Events: (0,
|
|
707
|
-
ruptelaEvents: (0,
|
|
708
|
-
polygons: (0,
|
|
709
|
-
polygonEvents: (0,
|
|
710
|
-
polygonCars: (0,
|
|
711
|
-
canbus: (0,
|
|
712
|
-
states: (0,
|
|
713
|
-
app_pro_commands_queue: (0,
|
|
714
|
-
trips: (0,
|
|
715
|
-
tripsDetails: (0,
|
|
716
|
-
audit: (0,
|
|
717
|
-
nx_settings: (0,
|
|
718
|
-
settings: (0,
|
|
719
|
-
translations: (0,
|
|
720
|
-
nx_cars: (0,
|
|
721
|
-
boards: (0,
|
|
722
|
-
protection_types: (0,
|
|
723
|
-
board_types: (0,
|
|
724
|
-
charge_capacities: (0,
|
|
769
|
+
clients: (0, import_firestore2.collection)(db, "nx-clients"),
|
|
770
|
+
sites: (0, import_firestore2.collection)(db, "nx-sites"),
|
|
771
|
+
cars: (0, import_firestore2.collection)(db, "units"),
|
|
772
|
+
users: (0, import_firestore2.collection)(db, "nx-users"),
|
|
773
|
+
lastLocations: (0, import_firestore2.collection)(db, "last_locations"),
|
|
774
|
+
ermEvents: (0, import_firestore2.collection)(db, "erm_events_general"),
|
|
775
|
+
erm2Events: (0, import_firestore2.collection)(db, "erm2_events_general"),
|
|
776
|
+
ruptelaEvents: (0, import_firestore2.collection)(db, "ruptela_events_general"),
|
|
777
|
+
polygons: (0, import_firestore2.collection)(db, "nx-polygons"),
|
|
778
|
+
polygonEvents: (0, import_firestore2.collection)(db, "polygon_events"),
|
|
779
|
+
polygonCars: (0, import_firestore2.collection)(db, "polygon_cars"),
|
|
780
|
+
canbus: (0, import_firestore2.collection)(db, "erm_canbus_parameters"),
|
|
781
|
+
states: (0, import_firestore2.collection)(db, "erm_states"),
|
|
782
|
+
app_pro_commands_queue: (0, import_firestore2.collection)(db, "app_pro_commands_queue"),
|
|
783
|
+
trips: (0, import_firestore2.collection)(db, "erm2_trip"),
|
|
784
|
+
tripsDetails: (0, import_firestore2.collection)(db, "erm2_trip_details"),
|
|
785
|
+
audit: (0, import_firestore2.collection)(db, "nx-audit"),
|
|
786
|
+
nx_settings: (0, import_firestore2.collection)(db, "nx-settings"),
|
|
787
|
+
settings: (0, import_firestore2.collection)(db, "settings"),
|
|
788
|
+
translations: (0, import_firestore2.collection)(db, "nx-translations"),
|
|
789
|
+
nx_cars: (0, import_firestore2.collection)(db, "nx-cars"),
|
|
790
|
+
boards: (0, import_firestore2.collection)(db, "boards"),
|
|
791
|
+
protection_types: (0, import_firestore2.collection)(db, "protectionTypes"),
|
|
792
|
+
board_types: (0, import_firestore2.collection)(db, "boardTypes"),
|
|
793
|
+
charge_capacities: (0, import_firestore2.collection)(db, "nx-charge-capacities")
|
|
725
794
|
};
|
|
726
|
-
var fire_base_TIME_TEMP =
|
|
795
|
+
var fire_base_TIME_TEMP = import_firestore2.Timestamp.now;
|
|
727
796
|
var simpleExtractData = function(doc2) {
|
|
728
797
|
var docData = doc2.data();
|
|
729
798
|
return _object_spread_props(_object_spread({}, docData), {
|
|
@@ -742,10 +811,10 @@ var set_document = /*#__PURE__*/ function() {
|
|
|
742
811
|
,
|
|
743
812
|
3
|
|
744
813
|
]);
|
|
745
|
-
doc_ref = (0,
|
|
814
|
+
doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
|
|
746
815
|
return [
|
|
747
816
|
4,
|
|
748
|
-
(0,
|
|
817
|
+
(0, import_firestore2.setDoc)(doc_ref, data, {
|
|
749
818
|
merge: true
|
|
750
819
|
})
|
|
751
820
|
];
|
|
@@ -792,10 +861,10 @@ var query_document = /*#__PURE__*/ function() {
|
|
|
792
861
|
,
|
|
793
862
|
4
|
|
794
863
|
]);
|
|
795
|
-
q = (0,
|
|
864
|
+
q = (0, import_firestore2.query)((0, import_firestore2.collection)(db, collection_path), (0, import_firestore2.where)(field_name, operator, value));
|
|
796
865
|
return [
|
|
797
866
|
4,
|
|
798
|
-
(0,
|
|
867
|
+
(0, import_firestore2.getDocs)(q)
|
|
799
868
|
];
|
|
800
869
|
case 2:
|
|
801
870
|
query_snapshot = _state.sent();
|
|
@@ -957,7 +1026,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
|
|
|
957
1026
|
,
|
|
958
1027
|
3
|
|
959
1028
|
]);
|
|
960
|
-
ref2 = (0,
|
|
1029
|
+
ref2 = (0, import_firestore2.doc)(collections.audit);
|
|
961
1030
|
data = {
|
|
962
1031
|
action: action,
|
|
963
1032
|
entity: entity,
|
|
@@ -972,7 +1041,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
|
|
|
972
1041
|
};
|
|
973
1042
|
return [
|
|
974
1043
|
4,
|
|
975
|
-
(0,
|
|
1044
|
+
(0, import_firestore2.setDoc)(ref2, _object_spread_props(_object_spread({}, data), {
|
|
976
1045
|
datetime: fire_base_TIME_TEMP()
|
|
977
1046
|
}))
|
|
978
1047
|
];
|
|
@@ -1153,74 +1222,6 @@ function cn() {
|
|
|
1153
1222
|
}
|
|
1154
1223
|
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
1155
1224
|
}
|
|
1156
|
-
// src/helpers/time_helpers.ts
|
|
1157
|
-
var import_firestore2 = require("firebase/firestore");
|
|
1158
|
-
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
1159
|
-
function timestamp_to_string(firebaseTimestamp, options) {
|
|
1160
|
-
var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
|
|
1161
|
-
var _ref = {
|
|
1162
|
-
defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
|
|
1163
|
-
format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
|
|
1164
|
-
fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
|
|
1165
|
-
tz: options === null || options === void 0 ? void 0 : options.tz,
|
|
1166
|
-
debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
|
|
1167
|
-
}, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
|
|
1168
|
-
var date;
|
|
1169
|
-
switch(true){
|
|
1170
|
-
case !firebaseTimestamp:
|
|
1171
|
-
{
|
|
1172
|
-
return defaultReturnedValue;
|
|
1173
|
-
}
|
|
1174
|
-
case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
|
|
1175
|
-
{
|
|
1176
|
-
date = firebaseTimestamp.toDate();
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
case _instanceof(firebaseTimestamp, Date):
|
|
1180
|
-
{
|
|
1181
|
-
date = firebaseTimestamp;
|
|
1182
|
-
break;
|
|
1183
|
-
}
|
|
1184
|
-
case typeof firebaseTimestamp === "string":
|
|
1185
|
-
{
|
|
1186
|
-
var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
|
|
1187
|
-
switch(m.isValid()){
|
|
1188
|
-
case true:
|
|
1189
|
-
date = m.toDate();
|
|
1190
|
-
break;
|
|
1191
|
-
default:
|
|
1192
|
-
return defaultReturnedValue;
|
|
1193
|
-
}
|
|
1194
|
-
break;
|
|
1195
|
-
}
|
|
1196
|
-
case !!firebaseTimestamp._seconds:
|
|
1197
|
-
{
|
|
1198
|
-
var ft = firebaseTimestamp;
|
|
1199
|
-
var _ft__nanoseconds;
|
|
1200
|
-
date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
|
|
1201
|
-
break;
|
|
1202
|
-
}
|
|
1203
|
-
case !!firebaseTimestamp.seconds:
|
|
1204
|
-
{
|
|
1205
|
-
var ft1 = firebaseTimestamp;
|
|
1206
|
-
date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
|
|
1207
|
-
break;
|
|
1208
|
-
}
|
|
1209
|
-
default:
|
|
1210
|
-
{
|
|
1211
|
-
if (debug) {
|
|
1212
|
-
console.error("Invalid timestamp format: ", firebaseTimestamp);
|
|
1213
|
-
}
|
|
1214
|
-
return defaultReturnedValue;
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
switch(Boolean(tz)){
|
|
1218
|
-
case true:
|
|
1219
|
-
return (0, import_moment_timezone.default)(date).tz(tz).format(format);
|
|
1220
|
-
default:
|
|
1221
|
-
return import_moment_timezone.default.utc(date).format(format);
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
1225
|
// src/helpers/api.ts
|
|
1225
1226
|
var import_axios2 = __toESM(require("axios"));
|
|
1226
1227
|
var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";
|
|
@@ -1237,57 +1238,6 @@ var import_axios3 = __toESM(require("axios"));
|
|
|
1237
1238
|
// src/helpers/socket.ts
|
|
1238
1239
|
var import_socket = require("socket.io-client");
|
|
1239
1240
|
var SESSION_STORAGE_KEY = "sessionId";
|
|
1240
|
-
var safeSessionStorage = function() {
|
|
1241
|
-
var memoryValue;
|
|
1242
|
-
var canUseStorage = function() {
|
|
1243
|
-
if (typeof window === "undefined") return false;
|
|
1244
|
-
try {
|
|
1245
|
-
var testKey = "".concat(SESSION_STORAGE_KEY, "_test");
|
|
1246
|
-
window.localStorage.setItem(testKey, "1");
|
|
1247
|
-
window.localStorage.removeItem(testKey);
|
|
1248
|
-
return true;
|
|
1249
|
-
} catch (error) {
|
|
1250
|
-
console.warn("localStorage check failed, falling back to memory store", error);
|
|
1251
|
-
return false;
|
|
1252
|
-
}
|
|
1253
|
-
};
|
|
1254
|
-
var storageAvailable = canUseStorage();
|
|
1255
|
-
return {
|
|
1256
|
-
read: function read() {
|
|
1257
|
-
if (!storageAvailable) {
|
|
1258
|
-
return memoryValue;
|
|
1259
|
-
}
|
|
1260
|
-
try {
|
|
1261
|
-
return window.localStorage.getItem(SESSION_STORAGE_KEY) || memoryValue;
|
|
1262
|
-
} catch (error) {
|
|
1263
|
-
console.warn("localStorage read failed, using memory store", error);
|
|
1264
|
-
return memoryValue;
|
|
1265
|
-
}
|
|
1266
|
-
},
|
|
1267
|
-
write: function write(value) {
|
|
1268
|
-
memoryValue = value;
|
|
1269
|
-
if (!storageAvailable || typeof value === "undefined") {
|
|
1270
|
-
return;
|
|
1271
|
-
}
|
|
1272
|
-
try {
|
|
1273
|
-
window.localStorage.setItem(SESSION_STORAGE_KEY, value);
|
|
1274
|
-
} catch (error) {
|
|
1275
|
-
console.warn("localStorage write failed, persisting in memory store", error);
|
|
1276
|
-
}
|
|
1277
|
-
},
|
|
1278
|
-
clear: function clear() {
|
|
1279
|
-
memoryValue = void 0;
|
|
1280
|
-
if (!storageAvailable) {
|
|
1281
|
-
return;
|
|
1282
|
-
}
|
|
1283
|
-
try {
|
|
1284
|
-
window.localStorage.removeItem(SESSION_STORAGE_KEY);
|
|
1285
|
-
} catch (error) {
|
|
1286
|
-
console.warn("localStorage clear failed", error);
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
|
-
}();
|
|
1291
1241
|
var SocketService = /*#__PURE__*/ function() {
|
|
1292
1242
|
"use strict";
|
|
1293
1243
|
function _SocketService() {
|
|
@@ -1308,7 +1258,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1308
1258
|
this.socket = (0, import_socket.io)(socketUrl, {
|
|
1309
1259
|
path: "/api/data-socket/connect",
|
|
1310
1260
|
auth: function(cb) {
|
|
1311
|
-
var sessionId =
|
|
1261
|
+
var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
|
|
1312
1262
|
var token = _this.authToken;
|
|
1313
1263
|
var authPayload = {};
|
|
1314
1264
|
if (token) authPayload.token = token;
|
|
@@ -1350,7 +1300,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1350
1300
|
this.socket.on("session", function(param) {
|
|
1351
1301
|
var session_id = param.session_id;
|
|
1352
1302
|
if (session_id) {
|
|
1353
|
-
|
|
1303
|
+
localStorage.setItem(SESSION_STORAGE_KEY, session_id);
|
|
1354
1304
|
}
|
|
1355
1305
|
});
|
|
1356
1306
|
this.socket.on("connect_error", function(error) {
|
|
@@ -358,12 +358,12 @@ function _ts_generator(thisArg, body) {
|
|
|
358
358
|
};
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
import
|
|
361
|
+
import moment2 from "moment";
|
|
362
362
|
import { initializeApp } from "firebase/app";
|
|
363
363
|
import { getStorage } from "firebase/storage";
|
|
364
364
|
import { getAuth, GoogleAuthProvider, signInWithPopup } from "firebase/auth";
|
|
365
365
|
import { initializeAppCheck, ReCaptchaEnterpriseProvider } from "firebase/app-check";
|
|
366
|
-
import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, Timestamp, where, getFirestore, onSnapshot, orderBy } from "firebase/firestore";
|
|
366
|
+
import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, Timestamp as Timestamp2, where, getFirestore, onSnapshot, orderBy } from "firebase/firestore";
|
|
367
367
|
import { useCallback } from "react";
|
|
368
368
|
// src/helpers/phoneNumber.ts
|
|
369
369
|
import { parsePhoneNumberFromString } from "libphonenumber-js";
|
|
@@ -412,6 +412,75 @@ var parsePermissions = function(object) {
|
|
|
412
412
|
};
|
|
413
413
|
// src/helpers/firebase.ts
|
|
414
414
|
import { ref, getDownloadURL, uploadBytes } from "firebase/storage";
|
|
415
|
+
// src/helpers/time_helpers.ts
|
|
416
|
+
import { Timestamp } from "firebase/firestore";
|
|
417
|
+
import moment from "moment-timezone";
|
|
418
|
+
function timestamp_to_string(firebaseTimestamp, options) {
|
|
419
|
+
var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
|
|
420
|
+
var _ref = {
|
|
421
|
+
defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
|
|
422
|
+
format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
|
|
423
|
+
fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
|
|
424
|
+
tz: options === null || options === void 0 ? void 0 : options.tz,
|
|
425
|
+
debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
|
|
426
|
+
}, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
|
|
427
|
+
var date;
|
|
428
|
+
switch(true){
|
|
429
|
+
case !firebaseTimestamp:
|
|
430
|
+
{
|
|
431
|
+
return defaultReturnedValue;
|
|
432
|
+
}
|
|
433
|
+
case _instanceof(firebaseTimestamp, Timestamp):
|
|
434
|
+
{
|
|
435
|
+
date = firebaseTimestamp.toDate();
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
case _instanceof(firebaseTimestamp, Date):
|
|
439
|
+
{
|
|
440
|
+
date = firebaseTimestamp;
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
case typeof firebaseTimestamp === "string":
|
|
444
|
+
{
|
|
445
|
+
var m = moment.utc(firebaseTimestamp, fromFormat);
|
|
446
|
+
switch(m.isValid()){
|
|
447
|
+
case true:
|
|
448
|
+
date = m.toDate();
|
|
449
|
+
break;
|
|
450
|
+
default:
|
|
451
|
+
return defaultReturnedValue;
|
|
452
|
+
}
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case !!firebaseTimestamp._seconds:
|
|
456
|
+
{
|
|
457
|
+
var ft = firebaseTimestamp;
|
|
458
|
+
var _ft__nanoseconds;
|
|
459
|
+
date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
case !!firebaseTimestamp.seconds:
|
|
463
|
+
{
|
|
464
|
+
var ft1 = firebaseTimestamp;
|
|
465
|
+
date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
default:
|
|
469
|
+
{
|
|
470
|
+
if (debug) {
|
|
471
|
+
console.error("Invalid timestamp format: ", firebaseTimestamp);
|
|
472
|
+
}
|
|
473
|
+
return defaultReturnedValue;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
switch(Boolean(tz)){
|
|
477
|
+
case true:
|
|
478
|
+
return moment(date).tz(tz).format(format);
|
|
479
|
+
default:
|
|
480
|
+
return moment.utc(date).format(format);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
// src/helpers/firebase.ts
|
|
415
484
|
var initApp = function() {
|
|
416
485
|
var isNodeEnv2 = typeof process !== "undefined" && process.env;
|
|
417
486
|
var firebaseConfig = {
|
|
@@ -502,7 +571,7 @@ var collections = {
|
|
|
502
571
|
board_types: collection(db, "boardTypes"),
|
|
503
572
|
charge_capacities: collection(db, "nx-charge-capacities")
|
|
504
573
|
};
|
|
505
|
-
var fire_base_TIME_TEMP =
|
|
574
|
+
var fire_base_TIME_TEMP = Timestamp2.now;
|
|
506
575
|
var simpleExtractData = function(doc2) {
|
|
507
576
|
var docData = doc2.data();
|
|
508
577
|
return _object_spread_props(_object_spread({}, docData), {
|
|
@@ -931,74 +1000,6 @@ function cn() {
|
|
|
931
1000
|
}
|
|
932
1001
|
return twMerge(clsx(inputs));
|
|
933
1002
|
}
|
|
934
|
-
// src/helpers/time_helpers.ts
|
|
935
|
-
import { Timestamp as Timestamp2 } from "firebase/firestore";
|
|
936
|
-
import moment2 from "moment-timezone";
|
|
937
|
-
function timestamp_to_string(firebaseTimestamp, options) {
|
|
938
|
-
var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
|
|
939
|
-
var _ref = {
|
|
940
|
-
defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
|
|
941
|
-
format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
|
|
942
|
-
fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
|
|
943
|
-
tz: options === null || options === void 0 ? void 0 : options.tz,
|
|
944
|
-
debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
|
|
945
|
-
}, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
|
|
946
|
-
var date;
|
|
947
|
-
switch(true){
|
|
948
|
-
case !firebaseTimestamp:
|
|
949
|
-
{
|
|
950
|
-
return defaultReturnedValue;
|
|
951
|
-
}
|
|
952
|
-
case _instanceof(firebaseTimestamp, Timestamp2):
|
|
953
|
-
{
|
|
954
|
-
date = firebaseTimestamp.toDate();
|
|
955
|
-
break;
|
|
956
|
-
}
|
|
957
|
-
case _instanceof(firebaseTimestamp, Date):
|
|
958
|
-
{
|
|
959
|
-
date = firebaseTimestamp;
|
|
960
|
-
break;
|
|
961
|
-
}
|
|
962
|
-
case typeof firebaseTimestamp === "string":
|
|
963
|
-
{
|
|
964
|
-
var m = moment2.utc(firebaseTimestamp, fromFormat);
|
|
965
|
-
switch(m.isValid()){
|
|
966
|
-
case true:
|
|
967
|
-
date = m.toDate();
|
|
968
|
-
break;
|
|
969
|
-
default:
|
|
970
|
-
return defaultReturnedValue;
|
|
971
|
-
}
|
|
972
|
-
break;
|
|
973
|
-
}
|
|
974
|
-
case !!firebaseTimestamp._seconds:
|
|
975
|
-
{
|
|
976
|
-
var ft = firebaseTimestamp;
|
|
977
|
-
var _ft__nanoseconds;
|
|
978
|
-
date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
|
|
979
|
-
break;
|
|
980
|
-
}
|
|
981
|
-
case !!firebaseTimestamp.seconds:
|
|
982
|
-
{
|
|
983
|
-
var ft1 = firebaseTimestamp;
|
|
984
|
-
date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
|
|
985
|
-
break;
|
|
986
|
-
}
|
|
987
|
-
default:
|
|
988
|
-
{
|
|
989
|
-
if (debug) {
|
|
990
|
-
console.error("Invalid timestamp format: ", firebaseTimestamp);
|
|
991
|
-
}
|
|
992
|
-
return defaultReturnedValue;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
switch(Boolean(tz)){
|
|
996
|
-
case true:
|
|
997
|
-
return moment2(date).tz(tz).format(format);
|
|
998
|
-
default:
|
|
999
|
-
return moment2.utc(date).format(format);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
1003
|
// src/helpers/api.ts
|
|
1003
1004
|
import axios2 from "axios";
|
|
1004
1005
|
var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";
|
|
@@ -1015,57 +1016,6 @@ import axios3 from "axios";
|
|
|
1015
1016
|
// src/helpers/socket.ts
|
|
1016
1017
|
import { io } from "socket.io-client";
|
|
1017
1018
|
var SESSION_STORAGE_KEY = "sessionId";
|
|
1018
|
-
var safeSessionStorage = function() {
|
|
1019
|
-
var memoryValue;
|
|
1020
|
-
var canUseStorage = function() {
|
|
1021
|
-
if (typeof window === "undefined") return false;
|
|
1022
|
-
try {
|
|
1023
|
-
var testKey = "".concat(SESSION_STORAGE_KEY, "_test");
|
|
1024
|
-
window.localStorage.setItem(testKey, "1");
|
|
1025
|
-
window.localStorage.removeItem(testKey);
|
|
1026
|
-
return true;
|
|
1027
|
-
} catch (error) {
|
|
1028
|
-
console.warn("localStorage check failed, falling back to memory store", error);
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
1031
|
-
};
|
|
1032
|
-
var storageAvailable = canUseStorage();
|
|
1033
|
-
return {
|
|
1034
|
-
read: function read() {
|
|
1035
|
-
if (!storageAvailable) {
|
|
1036
|
-
return memoryValue;
|
|
1037
|
-
}
|
|
1038
|
-
try {
|
|
1039
|
-
return window.localStorage.getItem(SESSION_STORAGE_KEY) || memoryValue;
|
|
1040
|
-
} catch (error) {
|
|
1041
|
-
console.warn("localStorage read failed, using memory store", error);
|
|
1042
|
-
return memoryValue;
|
|
1043
|
-
}
|
|
1044
|
-
},
|
|
1045
|
-
write: function write(value) {
|
|
1046
|
-
memoryValue = value;
|
|
1047
|
-
if (!storageAvailable || typeof value === "undefined") {
|
|
1048
|
-
return;
|
|
1049
|
-
}
|
|
1050
|
-
try {
|
|
1051
|
-
window.localStorage.setItem(SESSION_STORAGE_KEY, value);
|
|
1052
|
-
} catch (error) {
|
|
1053
|
-
console.warn("localStorage write failed, persisting in memory store", error);
|
|
1054
|
-
}
|
|
1055
|
-
},
|
|
1056
|
-
clear: function clear() {
|
|
1057
|
-
memoryValue = void 0;
|
|
1058
|
-
if (!storageAvailable) {
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
try {
|
|
1062
|
-
window.localStorage.removeItem(SESSION_STORAGE_KEY);
|
|
1063
|
-
} catch (error) {
|
|
1064
|
-
console.warn("localStorage clear failed", error);
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
1068
|
-
}();
|
|
1069
1019
|
var SocketService = /*#__PURE__*/ function() {
|
|
1070
1020
|
"use strict";
|
|
1071
1021
|
function _SocketService() {
|
|
@@ -1086,7 +1036,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1086
1036
|
this.socket = io(socketUrl, {
|
|
1087
1037
|
path: "/api/data-socket/connect",
|
|
1088
1038
|
auth: function(cb) {
|
|
1089
|
-
var sessionId =
|
|
1039
|
+
var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
|
|
1090
1040
|
var token = _this.authToken;
|
|
1091
1041
|
var authPayload = {};
|
|
1092
1042
|
if (token) authPayload.token = token;
|
|
@@ -1128,7 +1078,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1128
1078
|
this.socket.on("session", function(param) {
|
|
1129
1079
|
var session_id = param.session_id;
|
|
1130
1080
|
if (session_id) {
|
|
1131
|
-
|
|
1081
|
+
localStorage.setItem(SESSION_STORAGE_KEY, session_id);
|
|
1132
1082
|
}
|
|
1133
1083
|
});
|
|
1134
1084
|
this.socket.on("connect_error", function(error) {
|