@janiscommerce/app-tracking-shift 1.7.0-beta.1 → 1.7.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Formatter.js +1 -1
- package/lib/OfflineData.js +1 -1
- package/lib/Shift.js +19 -17
- package/lib/ShiftWorklogs.js +1 -1
- package/lib/StaffApiServices.js +2 -2
- package/lib/{utils → helpers}/provider/downloadWorkLogTypes/index.js +1 -1
- package/lib/{utils → helpers}/provider/openShift/index.js +1 -1
- package/lib/hooks/useStorageValue/index.js +2 -2
- package/lib/provider/ShiftTrackingProvider.js +2 -2
- package/package.json +1 -1
- /package/lib/{utils → helpers}/crashlytics/index.js +0 -0
- /package/lib/{utils → helpers}/errorParser/index.js +0 -0
- /package/lib/{utils/helpers → helpers}/index.js +0 -0
- /package/lib/{utils/helpers → helpers}/isApiError/index.js +0 -0
- /package/lib/{utils/helpers → helpers}/isInternetReachable/index.js +0 -0
- /package/lib/{utils → helpers}/provider/getShiftWorkLogsFromJanis/index.js +0 -0
- /package/lib/{utils → helpers}/provider/index.js +0 -0
- /package/lib/{utils → helpers}/provider/isAuthorizedToUseStaffMS/index.js +0 -0
- /package/lib/{utils → helpers}/request/index.js +0 -0
- /package/lib/{utils → helpers}/storage/getStaffAuthorizationData/index.js +0 -0
- /package/lib/{utils → helpers}/storage/getWorkLogTypesData/index.js +0 -0
- /package/lib/{utils → helpers}/storage/index.js +0 -0
- /package/lib/{utils → helpers}/userInfo/getUserId/index.js +0 -0
package/lib/Formatter.js
CHANGED
package/lib/OfflineData.js
CHANGED
package/lib/Shift.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import StaffService from './StaffApiServices';
|
|
2
2
|
import Storage from './db/StorageService';
|
|
3
|
-
import Crashlytics from './
|
|
3
|
+
import Crashlytics from './helpers/crashlytics';
|
|
4
4
|
import ShiftWorklogs from './ShiftWorklogs';
|
|
5
|
-
import errorParser from './
|
|
5
|
+
import errorParser from './helpers/errorParser';
|
|
6
6
|
import {
|
|
7
7
|
isArray,
|
|
8
8
|
isEmptyArray,
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
isInternetReachable,
|
|
13
13
|
isValidDate,
|
|
14
14
|
parseToISOString,
|
|
15
|
-
} from './
|
|
16
|
-
import {getStaffAuthorizationData} from './
|
|
15
|
+
} from './helpers';
|
|
16
|
+
import {getStaffAuthorizationData} from './helpers/storage';
|
|
17
17
|
import {
|
|
18
18
|
SHIFT_ID,
|
|
19
19
|
SHIFT_STATUS,
|
|
@@ -252,34 +252,34 @@ class Shift {
|
|
|
252
252
|
* @param {string} workLog.name => Name related to the work log
|
|
253
253
|
* @param {string} workLog.type => Type related to the work log
|
|
254
254
|
* @param {number} workLog.suggestedTime => Suggested time related to the work log
|
|
255
|
-
* @param {string|number}
|
|
255
|
+
* @param {string|number} workLog.startDate => Start date related to the work log. Accepts an ISO 8601 string (e.g. "2026-03-05T10:00:00.000Z") or milliseconds since epoch (e.g. 1709636400000). Defaults to current date if omitted or invalid.
|
|
256
256
|
* @throws {Error} error
|
|
257
257
|
* @returns {Promise<string>} workLogId => ID related to the work log that has just been opened for the user
|
|
258
258
|
*/
|
|
259
259
|
|
|
260
|
-
async openWorkLog(workLog = {}
|
|
260
|
+
async openWorkLog(workLog = {}) {
|
|
261
261
|
let previousWorkLog = {};
|
|
262
262
|
|
|
263
263
|
try {
|
|
264
264
|
Crashlytics.log('openWorkLog:', workLog);
|
|
265
265
|
|
|
266
|
-
const currentDate = isValidDate(startDate)
|
|
267
|
-
? parseToISOString(startDate)
|
|
268
|
-
: new Date().toISOString();
|
|
269
|
-
|
|
270
266
|
if (!isValidObject(workLog)) return null;
|
|
271
267
|
|
|
272
268
|
if (!this.hasStaffAuthorization) {
|
|
273
269
|
this._throwAuthorizationError();
|
|
274
270
|
}
|
|
271
|
+
|
|
272
|
+
workLog.startDate = isValidDate(workLog.startDate)
|
|
273
|
+
? parseToISOString(workLog.startDate)
|
|
274
|
+
: new Date().toISOString();
|
|
275
|
+
|
|
275
276
|
delete workLog.endDate;
|
|
276
277
|
|
|
277
278
|
if (this.hasWorkLogInProgress) {
|
|
278
|
-
|
|
279
|
-
previousWorkLog
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
};
|
|
279
|
+
previousWorkLog = this.getCurrentWorkLog();
|
|
280
|
+
delete previousWorkLog.startDate;
|
|
281
|
+
|
|
282
|
+
previousWorkLog.endDate = workLog.startDate;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
if (this._hasToPause(workLog.referenceId)) {
|
|
@@ -287,7 +287,6 @@ class Shift {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
workLog.id = ShiftWorklogs.createId(workLog.referenceId);
|
|
290
|
-
workLog.startDate = currentDate;
|
|
291
290
|
this.setCurrentWorkLog(workLog);
|
|
292
291
|
|
|
293
292
|
const hasInternet = await isInternetReachable();
|
|
@@ -326,6 +325,7 @@ class Shift {
|
|
|
326
325
|
* Finish a work log in the staff MS and record this event in the time tracking database.
|
|
327
326
|
* @param {Object} workLog
|
|
328
327
|
* @param {string} workLog.referenceId => Reference ID related to the work log
|
|
328
|
+
* @param {string|number} workLog.endDate => End date related to the work log. Accepts an ISO 8601 string (e.g. "2026-03-05T10:00:00.000Z") or milliseconds since epoch (e.g. 1709636400000). Defaults to current date if omitted or invalid.
|
|
329
329
|
* @throws {Error} error
|
|
330
330
|
* @returns {Promise<string>} workLogId => ID related to the work log that has just been closed for the user
|
|
331
331
|
*/
|
|
@@ -352,7 +352,9 @@ class Shift {
|
|
|
352
352
|
);
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
workLog.endDate =
|
|
355
|
+
workLog.endDate = isValidDate(workLog.endDate)
|
|
356
|
+
? parseToISOString(workLog.endDate)
|
|
357
|
+
: new Date().toISOString();
|
|
356
358
|
delete workLog.startDate;
|
|
357
359
|
|
|
358
360
|
if (this.isPaused) {
|
package/lib/ShiftWorklogs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {INTERNAL_WORKLOGS} from './constant';
|
|
2
2
|
import StaffApiServices from './StaffApiServices';
|
|
3
|
-
import {generateRandomId, isArray, isEmptyArray} from './
|
|
3
|
+
import {generateRandomId, isArray, isEmptyArray} from './helpers';
|
|
4
4
|
|
|
5
5
|
class ShiftWorklogs {
|
|
6
6
|
async open(params) {
|
package/lib/StaffApiServices.js
CHANGED
|
@@ -3,7 +3,7 @@ import {getWorkLogTypesData} from '../../storage';
|
|
|
3
3
|
import {WORKLOG_TYPES_DATA, WORKLOG_TYPES_EXPIRATION_TIME} from '../../../constant';
|
|
4
4
|
import Storage from '../../../db/StorageService';
|
|
5
5
|
import Crashlytics from '../../crashlytics';
|
|
6
|
-
import {isFunction} from '
|
|
6
|
+
import {isFunction} from '../..';
|
|
7
7
|
import errorParser from '../../errorParser';
|
|
8
8
|
|
|
9
9
|
const downloadWorkLogTypes = async (onDownloadError) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Crashlytics from '../../crashlytics';
|
|
2
2
|
import getUserId from '../../userInfo/getUserId';
|
|
3
3
|
import Shift from '../../../Shift';
|
|
4
|
-
import {isFunction} from '
|
|
4
|
+
import {isFunction} from '../..';
|
|
5
5
|
import errorParser from '../../errorParser';
|
|
6
6
|
|
|
7
7
|
const openShift = async ({onOpenShiftError, warehouseId}) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {useEffect, useState, useCallback} from 'react';
|
|
2
2
|
import Storage from '../../db/StorageService';
|
|
3
|
-
import Crashlytics from '../../
|
|
4
|
-
import errorParser from '../../
|
|
3
|
+
import Crashlytics from '../../helpers/crashlytics';
|
|
4
|
+
import errorParser from '../../helpers/errorParser';
|
|
5
5
|
|
|
6
6
|
export const useStorageValue = (key, defaultValue = null) => {
|
|
7
7
|
const readValue = useCallback(() => {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
downloadWorkLogTypes,
|
|
7
7
|
isAuthorizedToUseStaffMS,
|
|
8
8
|
getShiftWorkLogsFromJanis,
|
|
9
|
-
} from '../
|
|
9
|
+
} from '../helpers/provider';
|
|
10
10
|
import {
|
|
11
11
|
CURRENT_WORKLOG_DATA,
|
|
12
12
|
CURRENT_WORKLOG_ID,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
STAFF_AUTH,
|
|
18
18
|
WORKLOG_TYPES_DATA,
|
|
19
19
|
} from '../constant';
|
|
20
|
-
import {isValidObject, promiseWrapper} from '../
|
|
20
|
+
import {isValidObject, promiseWrapper} from '../helpers';
|
|
21
21
|
import Shift from '../Shift';
|
|
22
22
|
|
|
23
23
|
/**
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|