@monkvision/inspection-capture-web 5.0.1 → 5.0.3
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/PhotoCapture/PhotoCapture.js +17 -24
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.d.ts +10 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.js +2 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.d.ts +9 -5
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.js +2 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.d.ts +1 -1
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.js +2 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.d.ts +12 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.js +17 -9
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.styles.js +23 -7
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/hooks.d.ts +818 -0
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/hooks.js +26 -0
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.d.ts +9 -1
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.js +1 -1
- package/lib/PhotoCapture/hooks/index.d.ts +2 -0
- package/lib/PhotoCapture/hooks/index.js +2 -0
- package/lib/PhotoCapture/hooks/useInspectionComplete.d.ts +38 -0
- package/lib/PhotoCapture/hooks/useInspectionComplete.js +41 -0
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightGuidelines.d.ts +28 -0
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightGuidelines.js +42 -0
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.d.ts +11 -3
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.js +29 -16
- package/lib/PhotoCapture/hooks/usePhotoCaptureTutorial.d.ts +16 -6
- package/lib/components/HUDOverlay/HUDOverlay.styles.js +1 -1
- package/lib/hooks/useStartTasksOnComplete.js +5 -2
- package/lib/translations/de.json +3 -1
- package/lib/translations/en.json +3 -1
- package/lib/translations/fr.json +3 -1
- package/lib/translations/nl.json +3 -1
- package/package.json +15 -15
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.useSightGuidelineStyle = void 0;
|
|
15
|
+
var types_1 = require("@monkvision/types");
|
|
16
|
+
var SightGuideline_styles_1 = require("./SightGuideline.styles");
|
|
17
|
+
var hooks_1 = require("../../../../hooks");
|
|
18
|
+
function useSightGuidelineStyle(_a) {
|
|
19
|
+
var addDamage = _a.addDamage;
|
|
20
|
+
var backgroundColor = (0, hooks_1.useColorBackground)();
|
|
21
|
+
return {
|
|
22
|
+
container: addDamage === types_1.AddDamage.DISABLED ? SightGuideline_styles_1.styles['containerWide'] : SightGuideline_styles_1.styles['container'],
|
|
23
|
+
guideline: __assign(__assign({}, SightGuideline_styles_1.styles['guideline']), { backgroundColor: backgroundColor }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.useSightGuidelineStyle = useSightGuidelineStyle;
|
|
@@ -4,7 +4,7 @@ import { TutorialSteps } from '../../hooks';
|
|
|
4
4
|
/**
|
|
5
5
|
* Props of the PhotoCaptureHUDElementsSight component.
|
|
6
6
|
*/
|
|
7
|
-
export interface PhotoCaptureHUDElementsSightProps extends Pick<PhotoCaptureAppConfig, '
|
|
7
|
+
export interface PhotoCaptureHUDElementsSightProps extends Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage'> {
|
|
8
8
|
/**
|
|
9
9
|
* The list of sights provided to the PhotoCapture component.
|
|
10
10
|
*/
|
|
@@ -29,6 +29,10 @@ export interface PhotoCaptureHUDElementsSightProps extends Pick<PhotoCaptureAppC
|
|
|
29
29
|
* Callback called when the user clicks on the AddDamage button.
|
|
30
30
|
*/
|
|
31
31
|
onAddDamage?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
|
|
34
|
+
*/
|
|
35
|
+
onDisableSightGuidelines?: () => void;
|
|
32
36
|
/**
|
|
33
37
|
* Array containing the list of sights that the user has already captured.
|
|
34
38
|
*/
|
|
@@ -41,6 +45,10 @@ export interface PhotoCaptureHUDElementsSightProps extends Pick<PhotoCaptureAppC
|
|
|
41
45
|
* The current images taken by the user (ignoring retaken pictures etc.).
|
|
42
46
|
*/
|
|
43
47
|
images: Image[];
|
|
48
|
+
/**
|
|
49
|
+
* Boolean indicating whether the sight guidelines should be displayed.
|
|
50
|
+
*/
|
|
51
|
+
showSightGuidelines?: boolean;
|
|
44
52
|
}
|
|
45
53
|
export declare function usePhotoCaptureHUDSightPreviewStyle({ previewDimensions, }: Pick<PhotoCaptureHUDElementsSightProps, 'previewDimensions'>): {
|
|
46
54
|
container: import("@monkvision/types").ResponsiveStyleProperties;
|
|
@@ -33,6 +33,6 @@ function PhotoCaptureHUDTutorial(_a) {
|
|
|
33
33
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
34
34
|
var primaryColor = (0, hooks_2.useColorBackground)();
|
|
35
35
|
var style = (0, hooks_3.usePhotoCaptureHUDTutorialStyle)();
|
|
36
|
-
return currentTutorialStep ? ((0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['backdropContainer'], "data-testid": 'backdrop' }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['topContainer'] }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['buttonsContainer'] }, { children: [(0, jsx_runtime_1.jsx)("div", { style: PhotoCaptureHUDTutorial_styles_1.styles['closeButtonTwin'] }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.SightGuideline, { sightId: sightId, sightGuidelines: sightGuidelines,
|
|
36
|
+
return currentTutorialStep ? ((0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['backdropContainer'], "data-testid": 'backdrop' }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['topContainer'] }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['buttonsContainer'] }, { children: [(0, jsx_runtime_1.jsx)("div", { style: PhotoCaptureHUDTutorial_styles_1.styles['closeButtonTwin'] }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.SightGuideline, { sightId: sightId, sightGuidelines: sightGuidelines, disabled: currentTutorialStep !== hooks_1.TutorialSteps.GUIDELINE, addDamage: addDamage, enableDefaultMessage: true }), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, { style: __assign(__assign({}, PhotoCaptureHUDTutorial_styles_1.styles['closeButton']), getButtonStyle(allowSkipTutorial)), disabled: !allowSkipTutorial, icon: 'close', primaryColor: primaryColor, onClick: onCloseTutorial })] })), (0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['arrows'] }, { children: (0, jsx_runtime_1.jsx)(ArrowIcon_1.ArrowIcon, { tutorialStep: currentTutorialStep }) }))] })), (0, jsx_runtime_1.jsx)(DisplayText_1.DisplayText, { tutorialStep: currentTutorialStep }), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['nextButton'], primaryColor: 'primary', onClick: onNextTutorialStep }, { children: t('photo.hud.tutorial.next') }))] })) }))) : null;
|
|
37
37
|
}
|
|
38
38
|
exports.PhotoCaptureHUDTutorial = PhotoCaptureHUDTutorial;
|
|
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./usePhotoCaptureSightState"), exports);
|
|
18
18
|
__exportStar(require("./useComplianceAnalytics"), exports);
|
|
19
19
|
__exportStar(require("./usePhotoCaptureTutorial"), exports);
|
|
20
|
+
__exportStar(require("./usePhotoCaptureSightGuidelines"), exports);
|
|
21
|
+
__exportStar(require("./useInspectionComplete"), exports);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LoadingState } from '@monkvision/common';
|
|
2
|
+
import { PhotoCaptureAppConfig } from '@monkvision/types';
|
|
3
|
+
import { StartTasksFunction } from '../../hooks';
|
|
4
|
+
import { PhotoCaptureSightState } from './usePhotoCaptureSightState';
|
|
5
|
+
/**
|
|
6
|
+
* Parameters of the useInspectionComplete hook.
|
|
7
|
+
*/
|
|
8
|
+
export interface InspectionCompleteParams extends Pick<PhotoCaptureAppConfig, 'startTasksOnComplete'> {
|
|
9
|
+
/**
|
|
10
|
+
* Callback called when the user has started the inspection tasks.
|
|
11
|
+
*/
|
|
12
|
+
startTasks: StartTasksFunction;
|
|
13
|
+
/**
|
|
14
|
+
* The sight state, created using the usePhotoCaptureSightState hook.
|
|
15
|
+
*/
|
|
16
|
+
sightState: PhotoCaptureSightState;
|
|
17
|
+
/**
|
|
18
|
+
* Global loading state of the PhotoCapture component.
|
|
19
|
+
*/
|
|
20
|
+
loading: LoadingState;
|
|
21
|
+
/**
|
|
22
|
+
* Callback called when the user clicks on the "Complete" button in the HUD.
|
|
23
|
+
*/
|
|
24
|
+
onComplete?: () => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Handle used to manage the completion of the inspection.
|
|
28
|
+
*/
|
|
29
|
+
export interface InspectionCompleteHandle {
|
|
30
|
+
/**
|
|
31
|
+
* Callback called when the user has completed the inspection.
|
|
32
|
+
*/
|
|
33
|
+
handleInspectionCompleted: () => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Custom hook used to generate the callback called when the user has completed the inspection.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useInspectionComplete({ startTasks, sightState, loading, startTasksOnComplete, onComplete, }: InspectionCompleteParams): InspectionCompleteHandle;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInspectionComplete = void 0;
|
|
4
|
+
var common_1 = require("@monkvision/common");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
var analytics_1 = require("@monkvision/analytics");
|
|
7
|
+
var monitoring_1 = require("@monkvision/monitoring");
|
|
8
|
+
/**
|
|
9
|
+
* Custom hook used to generate the callback called when the user has completed the inspection.
|
|
10
|
+
*/
|
|
11
|
+
function useInspectionComplete(_a) {
|
|
12
|
+
var startTasks = _a.startTasks, sightState = _a.sightState, loading = _a.loading, startTasksOnComplete = _a.startTasksOnComplete, onComplete = _a.onComplete;
|
|
13
|
+
var analytics = (0, analytics_1.useAnalytics)();
|
|
14
|
+
var monitoring = (0, monitoring_1.useMonitoring)();
|
|
15
|
+
var allowRedirect = (0, common_1.usePreventExit)(sightState.sightsTaken.length !== 0).allowRedirect;
|
|
16
|
+
var handleInspectionCompleted = (0, react_1.useCallback)(function () {
|
|
17
|
+
startTasks()
|
|
18
|
+
.then(function () {
|
|
19
|
+
analytics.trackEvent('Capture Completed');
|
|
20
|
+
analytics.setUserProperties({
|
|
21
|
+
captureCompleted: true,
|
|
22
|
+
sightSelected: 'inspection-completed',
|
|
23
|
+
});
|
|
24
|
+
allowRedirect();
|
|
25
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
26
|
+
sightState.setIsInspectionCompleted(true);
|
|
27
|
+
})
|
|
28
|
+
.catch(function (err) {
|
|
29
|
+
loading.onError(err);
|
|
30
|
+
monitoring.handleError(err);
|
|
31
|
+
});
|
|
32
|
+
}, []);
|
|
33
|
+
(0, react_1.useEffect)(function () {
|
|
34
|
+
var isInspectionCompliant = sightState.isInspectionCompliant, isInspectionCompleted = sightState.isInspectionCompleted;
|
|
35
|
+
if (startTasksOnComplete && isInspectionCompliant && !isInspectionCompleted) {
|
|
36
|
+
handleInspectionCompleted();
|
|
37
|
+
}
|
|
38
|
+
}, [sightState.isInspectionCompliant]);
|
|
39
|
+
return (0, common_1.useObjectMemo)({ handleInspectionCompleted: handleInspectionCompleted });
|
|
40
|
+
}
|
|
41
|
+
exports.useInspectionComplete = useInspectionComplete;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PhotoCaptureAppConfig } from '@monkvision/types';
|
|
2
|
+
export declare const STORAGE_KEY_PHOTO_CAPTURE_GUIDELINES = "@monk_photoCaptureSightGuideline";
|
|
3
|
+
export declare const TTL_MS: number;
|
|
4
|
+
/**
|
|
5
|
+
* Parameters of the usePhotoCaptureSightGuidelines hook.
|
|
6
|
+
*/
|
|
7
|
+
export interface PhotoCaptureSightGuidelines extends Pick<PhotoCaptureAppConfig, 'enableSightGuidelines'> {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Handle returned by the usePhotoCaptureSightGuidelines hook to manage the SightGuidelines feature.
|
|
11
|
+
*/
|
|
12
|
+
export interface PhotoCaptureSightGuidelinesHandle {
|
|
13
|
+
/**
|
|
14
|
+
* Boolean indicating if the sight guidelines are enabled or not.
|
|
15
|
+
*/
|
|
16
|
+
showSightGuidelines: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
|
|
19
|
+
*/
|
|
20
|
+
onDisableSightGuidelines?: () => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Custom hook used to manage the state of photo capture sight guidelines.
|
|
24
|
+
*/
|
|
25
|
+
export declare function usePhotoCaptureSightGuidelines({ enableSightGuidelines, }: PhotoCaptureSightGuidelines): {
|
|
26
|
+
showSightGuidelines: boolean;
|
|
27
|
+
handleDisableSightGuidelines: () => void;
|
|
28
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePhotoCaptureSightGuidelines = exports.TTL_MS = exports.STORAGE_KEY_PHOTO_CAPTURE_GUIDELINES = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var types_1 = require("@monkvision/types");
|
|
6
|
+
var common_1 = require("@monkvision/common");
|
|
7
|
+
exports.STORAGE_KEY_PHOTO_CAPTURE_GUIDELINES = '@monk_photoCaptureSightGuideline';
|
|
8
|
+
exports.TTL_MS = 48 * 60 * 60 * 1000;
|
|
9
|
+
function isTTLExpired() {
|
|
10
|
+
var timestamp = localStorage.getItem(exports.STORAGE_KEY_PHOTO_CAPTURE_GUIDELINES);
|
|
11
|
+
return !timestamp || Date.now() - parseInt(timestamp, 10) > exports.TTL_MS;
|
|
12
|
+
}
|
|
13
|
+
function getShowSightGuidelines(enableSightGuidelines) {
|
|
14
|
+
switch (enableSightGuidelines) {
|
|
15
|
+
case types_1.PhotoCaptureSightGuidelinesOption.DISABLED:
|
|
16
|
+
return false;
|
|
17
|
+
case types_1.PhotoCaptureSightGuidelinesOption.EPHEMERAL:
|
|
18
|
+
return isTTLExpired();
|
|
19
|
+
default:
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Custom hook used to manage the state of photo capture sight guidelines.
|
|
25
|
+
*/
|
|
26
|
+
function usePhotoCaptureSightGuidelines(_a) {
|
|
27
|
+
var enableSightGuidelines = _a.enableSightGuidelines;
|
|
28
|
+
var _b = (0, react_1.useState)(function () {
|
|
29
|
+
return getShowSightGuidelines(enableSightGuidelines);
|
|
30
|
+
}), showSightGuidelines = _b[0], setShowSightGuidelines = _b[1];
|
|
31
|
+
var handleDisableSightGuidelines = (0, react_1.useCallback)(function () {
|
|
32
|
+
if (enableSightGuidelines === types_1.PhotoCaptureSightGuidelinesOption.EPHEMERAL) {
|
|
33
|
+
localStorage.setItem(exports.STORAGE_KEY_PHOTO_CAPTURE_GUIDELINES, Date.now().toString());
|
|
34
|
+
setShowSightGuidelines(false);
|
|
35
|
+
}
|
|
36
|
+
if (enableSightGuidelines === types_1.PhotoCaptureSightGuidelinesOption.ENABLED) {
|
|
37
|
+
setShowSightGuidelines(false);
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
return (0, common_1.useObjectMemo)({ showSightGuidelines: showSightGuidelines, handleDisableSightGuidelines: handleDisableSightGuidelines });
|
|
41
|
+
}
|
|
42
|
+
exports.usePhotoCaptureSightGuidelines = usePhotoCaptureSightGuidelines;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { MonkApiConfig } from '@monkvision/network';
|
|
3
3
|
import { LoadingState } from '@monkvision/common';
|
|
4
|
-
import { ComplianceOptions, Sight, TaskName } from '@monkvision/types';
|
|
4
|
+
import { ComplianceOptions, Sight, TaskName, PhotoCaptureAppConfig } from '@monkvision/types';
|
|
5
5
|
/**
|
|
6
6
|
* Object containing state management utilities for the PhotoCapture sights.
|
|
7
7
|
*/
|
|
@@ -46,11 +46,15 @@ export interface PhotoCaptureSightState {
|
|
|
46
46
|
* Callback used to manually update the completion state of the inspection.
|
|
47
47
|
*/
|
|
48
48
|
setIsInspectionCompleted: Dispatch<SetStateAction<boolean>>;
|
|
49
|
+
/**
|
|
50
|
+
* Boolean indicating if the inspection is compliant or not.
|
|
51
|
+
*/
|
|
52
|
+
isInspectionCompliant: boolean;
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Parameters of the usePhotoCaptureSightState hook.
|
|
52
56
|
*/
|
|
53
|
-
export interface PhotoCaptureSightsParams {
|
|
57
|
+
export interface PhotoCaptureSightsParams extends Pick<PhotoCaptureAppConfig, 'startTasksOnComplete'> {
|
|
54
58
|
/**
|
|
55
59
|
* The inspection ID.
|
|
56
60
|
*/
|
|
@@ -84,9 +88,13 @@ export interface PhotoCaptureSightsParams {
|
|
|
84
88
|
* sight will be used.
|
|
85
89
|
*/
|
|
86
90
|
tasksBySight?: Record<string, TaskName[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Callback called when inspection capture is complete.
|
|
93
|
+
*/
|
|
94
|
+
onComplete?: () => void;
|
|
87
95
|
}
|
|
88
96
|
/**
|
|
89
97
|
* Custom hook used to manage the state of the PhotoCapture sights. This state is automatically fetched from the API at
|
|
90
98
|
* the start of the PhotoCapture process in order to allow users to start the inspection where they left it before.
|
|
91
99
|
*/
|
|
92
|
-
export declare function usePhotoCaptureSightState({ inspectionId, captureSights, apiConfig, loading, onLastSightTaken, tasksBySight, setIsInitialInspectionFetched, complianceOptions, }: PhotoCaptureSightsParams): PhotoCaptureSightState;
|
|
100
|
+
export declare function usePhotoCaptureSightState({ inspectionId, captureSights, apiConfig, loading, onLastSightTaken, tasksBySight, setIsInitialInspectionFetched, complianceOptions, startTasksOnComplete, onComplete, }: PhotoCaptureSightsParams): PhotoCaptureSightState;
|
|
@@ -55,12 +55,28 @@ function getLastPictureTakenUri(inspectionId, response) {
|
|
|
55
55
|
var images = response.entities.images.filter(function (image) { return image.inspectionId === inspectionId; });
|
|
56
56
|
return images && images.length > 0 ? images[images.length - 1].path : null;
|
|
57
57
|
}
|
|
58
|
+
function getNotCompliantSights(inspectionId, captureSights, entities, notCompliantStatus) {
|
|
59
|
+
if (notCompliantStatus === void 0) { notCompliantStatus = [types_1.ImageStatus.NOT_COMPLIANT, types_1.ImageStatus.UPLOAD_FAILED]; }
|
|
60
|
+
return captureSights
|
|
61
|
+
.map(function (s) { return ({
|
|
62
|
+
sight: s,
|
|
63
|
+
image: (0, common_1.getInspectionImages)(inspectionId, entities.images, undefined, true).find(function (i) { return i.inspectionId === inspectionId && i.sightId === s.id; }),
|
|
64
|
+
}); })
|
|
65
|
+
.filter(function (_a) {
|
|
66
|
+
var image = _a.image;
|
|
67
|
+
return !!image && notCompliantStatus.includes(image.status);
|
|
68
|
+
})
|
|
69
|
+
.map(function (_a) {
|
|
70
|
+
var sight = _a.sight;
|
|
71
|
+
return sight;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
58
74
|
/**
|
|
59
75
|
* Custom hook used to manage the state of the PhotoCapture sights. This state is automatically fetched from the API at
|
|
60
76
|
* the start of the PhotoCapture process in order to allow users to start the inspection where they left it before.
|
|
61
77
|
*/
|
|
62
78
|
function usePhotoCaptureSightState(_a) {
|
|
63
|
-
var inspectionId = _a.inspectionId, captureSights = _a.captureSights, apiConfig = _a.apiConfig, loading = _a.loading, onLastSightTaken = _a.onLastSightTaken, tasksBySight = _a.tasksBySight, setIsInitialInspectionFetched = _a.setIsInitialInspectionFetched, complianceOptions = _a.complianceOptions;
|
|
79
|
+
var inspectionId = _a.inspectionId, captureSights = _a.captureSights, apiConfig = _a.apiConfig, loading = _a.loading, onLastSightTaken = _a.onLastSightTaken, tasksBySight = _a.tasksBySight, setIsInitialInspectionFetched = _a.setIsInitialInspectionFetched, complianceOptions = _a.complianceOptions, startTasksOnComplete = _a.startTasksOnComplete, onComplete = _a.onComplete;
|
|
64
80
|
if (captureSights.length === 0) {
|
|
65
81
|
throw new Error('Empty sight list given to the Monk PhotoCapture component.');
|
|
66
82
|
}
|
|
@@ -96,20 +112,7 @@ function usePhotoCaptureSightState(_a) {
|
|
|
96
112
|
}
|
|
97
113
|
else {
|
|
98
114
|
onLastSightTaken();
|
|
99
|
-
var notCompliantSights = captureSights
|
|
100
|
-
.map(function (s) { return ({
|
|
101
|
-
sight: s,
|
|
102
|
-
image: (0, common_1.getInspectionImages)(inspectionId, state.images, undefined, true).find(function (i) { return i.inspectionId === inspectionId && i.sightId === s.id; }),
|
|
103
|
-
}); })
|
|
104
|
-
.filter(function (_a) {
|
|
105
|
-
var image = _a.image;
|
|
106
|
-
return !!image &&
|
|
107
|
-
[types_1.ImageStatus.NOT_COMPLIANT, types_1.ImageStatus.UPLOAD_FAILED].includes(image.status);
|
|
108
|
-
})
|
|
109
|
-
.map(function (_a) {
|
|
110
|
-
var sight = _a.sight;
|
|
111
|
-
return sight;
|
|
112
|
-
});
|
|
115
|
+
var notCompliantSights = getNotCompliantSights(inspectionId, captureSights, state);
|
|
113
116
|
var sightToRetake_1 = notCompliantSights.length > 0
|
|
114
117
|
? notCompliantSights[0]
|
|
115
118
|
: captureSights[captureSights.length - 1];
|
|
@@ -145,6 +148,15 @@ function usePhotoCaptureSightState(_a) {
|
|
|
145
148
|
var retryLoadingInspection = (0, react_1.useCallback)(function () {
|
|
146
149
|
setRetryCount(function (value) { return value + 1; });
|
|
147
150
|
}, []);
|
|
151
|
+
var isInspectionCompliant = (0, react_1.useMemo)(function () {
|
|
152
|
+
var notCapturedSights = captureSights.filter(function (s) { return !sightsTaken.includes(s); });
|
|
153
|
+
var notCompliantSights = getNotCompliantSights(inspectionId, captureSights, state, [
|
|
154
|
+
types_1.ImageStatus.UPLOADING,
|
|
155
|
+
types_1.ImageStatus.NOT_COMPLIANT,
|
|
156
|
+
types_1.ImageStatus.UPLOAD_FAILED,
|
|
157
|
+
]);
|
|
158
|
+
return !notCapturedSights.length && !notCompliantSights.length;
|
|
159
|
+
}, [state.images]);
|
|
148
160
|
var takeSelectedSight = (0, react_1.useCallback)(function () {
|
|
149
161
|
var _a, _b;
|
|
150
162
|
var isRetake = sightsTaken.includes(selectedSight);
|
|
@@ -168,7 +180,7 @@ function usePhotoCaptureSightState(_a) {
|
|
|
168
180
|
if (nextSight) {
|
|
169
181
|
setSelectedSight(nextSight);
|
|
170
182
|
}
|
|
171
|
-
else {
|
|
183
|
+
else if (!startTasksOnComplete || !onComplete) {
|
|
172
184
|
onLastSightTaken();
|
|
173
185
|
}
|
|
174
186
|
}, [sightsTaken, selectedSight, captureSights, onLastSightTaken]);
|
|
@@ -201,6 +213,7 @@ function usePhotoCaptureSightState(_a) {
|
|
|
201
213
|
setLastPictureTakenUri: setLastPictureTakenUri,
|
|
202
214
|
retryLoadingInspection: retryLoadingInspection,
|
|
203
215
|
retakeSight: retakeSight,
|
|
216
|
+
isInspectionCompliant: isInspectionCompliant,
|
|
204
217
|
});
|
|
205
218
|
}
|
|
206
219
|
exports.usePhotoCaptureSightState = usePhotoCaptureSightState;
|
|
@@ -24,13 +24,23 @@ export declare enum TutorialSteps {
|
|
|
24
24
|
/**
|
|
25
25
|
* Parameters of the usePhotoCaptureTutorial hook.
|
|
26
26
|
*/
|
|
27
|
-
export interface
|
|
27
|
+
export interface PhotoCaptureTutorialParams extends Pick<PhotoCaptureAppConfig, 'enableTutorial' | 'enableSightTutorial' | 'enableSightGuidelines'> {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
export interface HandlePhotoCaptureTutorial {
|
|
30
|
+
/**
|
|
31
|
+
* The current tutorial step in PhotoCapture component.
|
|
32
|
+
*/
|
|
33
33
|
currentTutorialStep: TutorialSteps | null;
|
|
34
|
+
/**
|
|
35
|
+
* Callback called when the user clicks on the "Next" button in PhotoCapture tutorial.
|
|
36
|
+
*/
|
|
34
37
|
goToNextTutorialStep: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Callback called when the user clicks on the "Close" button in PhotoCapture tutorial.
|
|
40
|
+
*/
|
|
35
41
|
closeTutorial: () => void;
|
|
36
|
-
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Custom hook used to manage the state of photo capture tutorial.
|
|
45
|
+
*/
|
|
46
|
+
export declare function usePhotoCaptureTutorial({ enableTutorial, enableSightTutorial, enableSightGuidelines, }: PhotoCaptureTutorialParams): HandlePhotoCaptureTutorial;
|
|
@@ -59,7 +59,10 @@ function getTasksToStart(_a) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
return tasks.filter(function (task) {
|
|
62
|
+
return tasks.filter(function (task) {
|
|
63
|
+
return !TASKS_NOT_TO_START.includes(task) &&
|
|
64
|
+
!(task === types_1.TaskName.COMPLIANCES && tasks.includes(types_1.TaskName.DAMAGE_DETECTION));
|
|
65
|
+
});
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
68
|
* Custom hook used to generate a callback called at the end of the PhotoCapture inspection in order to automatically
|
|
@@ -79,10 +82,10 @@ function useStartTasksOnComplete(_a) {
|
|
|
79
82
|
return [2 /*return*/];
|
|
80
83
|
}
|
|
81
84
|
names = getTasksToStart({ sights: sights, additionalTasks: additionalTasks, tasksBySight: tasksBySight, startTasksOnComplete: startTasksOnComplete });
|
|
82
|
-
loading.start();
|
|
83
85
|
_a.label = 1;
|
|
84
86
|
case 1:
|
|
85
87
|
_a.trys.push([1, 3, , 4]);
|
|
88
|
+
loading.start();
|
|
86
89
|
return [4 /*yield*/, startInspectionTasks({ inspectionId: inspectionId, names: names })];
|
|
87
90
|
case 2:
|
|
88
91
|
_a.sent();
|
package/lib/translations/de.json
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"confirm": "Ja"
|
|
32
32
|
},
|
|
33
33
|
"guidelines": {
|
|
34
|
-
"defaultGuideline": "Blickwinkelanzeigen für Bilder können hier angezeigt werden."
|
|
34
|
+
"defaultGuideline": "Blickwinkelanzeigen für Bilder können hier angezeigt werden.",
|
|
35
|
+
"disable": "Nicht mehr anzeigen",
|
|
36
|
+
"validate": "Okay"
|
|
35
37
|
},
|
|
36
38
|
"tutorial": {
|
|
37
39
|
"welcome": "Willkommen zu Ihrer ersten Inspektion!",
|
package/lib/translations/en.json
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"confirm": "Yes"
|
|
32
32
|
},
|
|
33
33
|
"guidelines": {
|
|
34
|
-
"defaultGuideline": "Picture view point indications can be displayed here."
|
|
34
|
+
"defaultGuideline": "Picture view point indications can be displayed here.",
|
|
35
|
+
"disable": "Don't show this again",
|
|
36
|
+
"validate": "Okay"
|
|
35
37
|
},
|
|
36
38
|
"tutorial": {
|
|
37
39
|
"welcome": "Welcome to your first inspection!",
|
package/lib/translations/fr.json
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"confirm": "Oui"
|
|
32
32
|
},
|
|
33
33
|
"guidelines": {
|
|
34
|
-
"defaultGuideline": "Les indications de point de vue de l'image peuvent être affichées ici."
|
|
34
|
+
"defaultGuideline": "Les indications de point de vue de l'image peuvent être affichées ici.",
|
|
35
|
+
"disable": "Ne plus afficher",
|
|
36
|
+
"validate": "D'accord"
|
|
35
37
|
},
|
|
36
38
|
"tutorial": {
|
|
37
39
|
"welcome": "Bienvenue à votre première inspection!",
|
package/lib/translations/nl.json
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"confirm": "Ja"
|
|
32
32
|
},
|
|
33
33
|
"guidelines": {
|
|
34
|
-
"defaultGuideline": "Afbeeldingsstandpuntaanwijzingen kunnen hier worden weergegeven."
|
|
34
|
+
"defaultGuideline": "Afbeeldingsstandpuntaanwijzingen kunnen hier worden weergegeven.",
|
|
35
|
+
"disable": "Niet meer tonen",
|
|
36
|
+
"validate": "Oké"
|
|
35
37
|
},
|
|
36
38
|
"tutorial": {
|
|
37
39
|
"welcome": "Welkom bij uw eerste inspectie!",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkvision/inspection-capture-web",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"license": "BSD-3-Clause-Clear",
|
|
5
5
|
"packageManager": "yarn@3.2.4",
|
|
6
6
|
"description": "MonkJs inspection capture package for React (web) used to implement the Monk inspection capture workflow",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"lint:fix": "yarn run prettier:fix && yarn run eslint:fix"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@monkvision/analytics": "5.0.
|
|
32
|
-
"@monkvision/camera-web": "5.0.
|
|
33
|
-
"@monkvision/common": "5.0.
|
|
34
|
-
"@monkvision/common-ui-web": "5.0.
|
|
35
|
-
"@monkvision/network": "5.0.
|
|
36
|
-
"@monkvision/sights": "5.0.
|
|
31
|
+
"@monkvision/analytics": "5.0.3",
|
|
32
|
+
"@monkvision/camera-web": "5.0.3",
|
|
33
|
+
"@monkvision/common": "5.0.3",
|
|
34
|
+
"@monkvision/common-ui-web": "5.0.3",
|
|
35
|
+
"@monkvision/network": "5.0.3",
|
|
36
|
+
"@monkvision/sights": "5.0.3",
|
|
37
37
|
"i18next": "^23.4.5",
|
|
38
38
|
"react-i18next": "^13.2.0"
|
|
39
39
|
},
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"react-router-dom": "^6.22.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@monkvision/eslint-config-base": "5.0.
|
|
48
|
-
"@monkvision/eslint-config-typescript": "5.0.
|
|
49
|
-
"@monkvision/eslint-config-typescript-react": "5.0.
|
|
50
|
-
"@monkvision/jest-config": "5.0.
|
|
51
|
-
"@monkvision/prettier-config": "5.0.
|
|
52
|
-
"@monkvision/test-utils": "5.0.
|
|
53
|
-
"@monkvision/typescript-config": "5.0.
|
|
47
|
+
"@monkvision/eslint-config-base": "5.0.3",
|
|
48
|
+
"@monkvision/eslint-config-typescript": "5.0.3",
|
|
49
|
+
"@monkvision/eslint-config-typescript-react": "5.0.3",
|
|
50
|
+
"@monkvision/jest-config": "5.0.3",
|
|
51
|
+
"@monkvision/prettier-config": "5.0.3",
|
|
52
|
+
"@monkvision/test-utils": "5.0.3",
|
|
53
|
+
"@monkvision/typescript-config": "5.0.3",
|
|
54
54
|
"@testing-library/react": "^12.1.5",
|
|
55
55
|
"@testing-library/react-hooks": "^8.0.1",
|
|
56
56
|
"@types/copyfiles": "^2",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"url": "https://github.com/monkvision/monkjs/issues"
|
|
94
94
|
},
|
|
95
95
|
"homepage": "https://github.com/monkvision/monkjs",
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "d7576e6acbe6c891822d9eafaa838414175f64b4"
|
|
97
97
|
}
|