Skip to content

Commit 30c75fb

Browse files
Merge pull request #375 from monkvision/feature/custom-drivably-events
feat: Added custom events for Drivably
2 parents 1d352f4 + 0c7e3a4 commit 30c75fb

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

packages/camera/src/components/Capture/capture.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ const Capture = forwardRef(({
9393
onWarningMessage,
9494
onReady,
9595
onRetakeAll,
96+
onRetakeNeeded,
97+
onSkipRetake,
9698
onStartUploadPicture,
9799
onFinishUploadPicture,
98100
orientationBlockerProps,
@@ -331,6 +333,8 @@ const Capture = forwardRef(({
331333
onComplianceCheckFinish={onComplianceCheckFinish}
332334
onComplianceCheckStart={onComplianceCheckStart}
333335
onRetakeAll={onRetakeAll}
336+
onSkipRetake={onSkipRetake}
337+
onRetakeNeeded={onRetakeNeeded}
334338
task={task}
335339
mapTasksToSights={mapTasksToSights}
336340
inspectionId={inspectionId}
@@ -479,8 +483,10 @@ Capture.propTypes = {
479483
onPictureUploaded: PropTypes.func,
480484
onReady: PropTypes.func,
481485
onRetakeAll: PropTypes.func,
486+
onRetakeNeeded: PropTypes.func,
482487
onSettingsChange: PropTypes.func,
483488
onSightsChange: PropTypes.func,
489+
onSkipRetake: PropTypes.func,
484490
onStartUploadPicture: PropTypes.func,
485491
onUploadsChange: PropTypes.func,
486492
onWarningMessage: PropTypes.func,
@@ -575,6 +581,7 @@ Capture.defaultProps = {
575581
onComplianceChange: () => {},
576582
onSettingsChange: () => {},
577583
onSightsChange: () => {},
584+
onSkipRetake: () => {},
578585
onUploadsChange: () => {},
579586
onComplianceCheckFinish: () => {},
580587
onComplianceCheckStart: () => {},
@@ -583,6 +590,7 @@ Capture.defaultProps = {
583590
onReady: () => {},
584591
onStartUploadPicture: () => {},
585592
onRetakeAll: () => {},
593+
onRetakeNeeded: () => {},
586594
orientationBlockerProps: null,
587595
primaryColor: '#FFF',
588596
resolutionOptions: undefined,

packages/camera/src/components/UploadCenter/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export default function UploadCenter({
6161
onComplianceCheckFinish,
6262
onComplianceCheckStart,
6363
onRetakeAll,
64+
onRetakeNeeded,
65+
onSkipRetake,
6466
checkComplianceAsync,
6567
inspectionId,
6668
task,
@@ -125,6 +127,37 @@ export default function UploadCenter({
125127
onComplianceCheckStart();
126128
}, [onComplianceCheckStart]);
127129

130+
const statEventsData = useMemo(() => ({
131+
retakesNeeded: ids.length,
132+
compliances: Object.entries(compliance.state)
133+
.filter(([key]) => ids.includes(key))
134+
.map(([, value]) => ({
135+
sightId: value?.id,
136+
error: value?.error,
137+
result: {
138+
coverage360: {
139+
isCompliant: value?.result?.data?.compliances?.coverage_360?.is_compliant,
140+
reasons: value?.result?.data?.compliances?.coverage_360?.reasons,
141+
status: value?.result?.data?.compliances?.coverage_360?.status,
142+
},
143+
image_quality_assessment: {
144+
isCompliant: value?.result?.data?.compliances?.image_quality_assessment?.is_compliant,
145+
reasons: value?.result?.data?.compliances?.image_quality_assessment?.reasons,
146+
status: value?.result?.data?.compliances?.image_quality_assessment?.status,
147+
},
148+
zoom_level: {
149+
isCompliant: value?.result?.data?.compliances?.zoom_level?.is_compliant,
150+
reasons: value?.result?.data?.compliances?.zoom_level?.reasons,
151+
status: value?.result?.data?.compliances?.zoom_level?.status,
152+
},
153+
},
154+
})),
155+
}), [ids, compliance.state]);
156+
157+
useEffect(() => {
158+
onRetakeNeeded(statEventsData);
159+
}, [ids.length, onRetakeNeeded]);
160+
128161
// END EFFECTS //
129162
// RENDERING //
130163

@@ -204,6 +237,7 @@ export default function UploadCenter({
204237
color={colors.actions.secondary}
205238
onPress={(e) => {
206239
log(['[Click] Skip retaking photo']);
240+
onSkipRetake(statEventsData);
207241
onComplianceCheckFinish(e);
208242
}}
209243
disabled={isSubmitting || hasAllRejected
@@ -266,6 +300,8 @@ UploadCenter.propTypes = {
266300
onComplianceCheckFinish: PropTypes.func,
267301
onComplianceCheckStart: PropTypes.func,
268302
onRetakeAll: PropTypes.func,
303+
onRetakeNeeded: PropTypes.func,
304+
onSkipRetake: PropTypes.func,
269305
Sentry: PropTypes.any,
270306
sights: PropTypes.objectOf(PropTypes.any).isRequired,
271307
task: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
@@ -277,6 +313,8 @@ UploadCenter.defaultProps = {
277313
onComplianceCheckStart: () => {},
278314
checkComplianceAsync: () => {},
279315
onRetakeAll: () => {},
316+
onRetakeNeeded: () => {},
317+
onSkipRetake: () => {},
280318
inspectionId: null,
281319
isSubmitting: false,
282320
mapTasksToSights: [],

src/screens/InspectionCapture/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ export default function InspectionCapture() {
214214
onComplianceCheckFinish={() => setSuccess(true)}
215215
colors={colors}
216216
Sentry={Sentry}
217-
218217
/>
219218
<Notice />
220219
</View>

website/docs/js/api/components/Capture.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,44 @@ Will call a function when pressing `retakeAll` button inside the Upload Center (
357357
const handleRetakeAll = () => console.log('Retaking all...');
358358
```
359359

360+
## onRetakeNeeded and onSkipRetake
361+
`PropTypes.func`
362+
363+
onRetakeNeeded : Will call a function when the number of pictures to be retaken changes inside the Upload Center (picture quality check screen).
364+
onSkipRetake : Will call a function when pressing the skip retake button inside the Upload Center (picture quality check screen).
365+
366+
```js
367+
const onRetakeNeeded = (result) => console.log(result);
368+
const onSkipRetake = (result) => console.log(result);
369+
/**
370+
* Result :
371+
* {
372+
* retakesNeeded, // The number of pictures to be retaken
373+
* compliances: [{ // Array of compliance results
374+
* sightId, // The id of the picture sight
375+
* error, // The error if there is one
376+
* result: { // The result of the compliance check
377+
* coverage360: { // Compliance result for the car coverage check
378+
* isCompliant, // Is it compliant
379+
* reasons, // Array of reasons is it is not compliant
380+
* status, // Status of the compliance check
381+
* },
382+
* image_quality_assessment: { // Compliance result for the image quality check
383+
* isCompliant, // Is it compliant
384+
* reasons, // Array of reasons is it is not compliant
385+
* status, // Status of the compliance check
386+
* },
387+
* zoom_level: { // Compliance result for the zoom level check
388+
* isCompliant, // Is it compliant
389+
* reasons, // Array of reasons is it is not compliant
390+
* status, // Status of the compliance check
391+
* },
392+
* },
393+
* }],
394+
* }
395+
*/
396+
```
397+
360398
## onStartUploadPicture
361399
`PropTypes.func`
362400

0 commit comments

Comments
 (0)