Skip to content

Commit

Permalink
feat: onNavigateToNextSight callback (MN-504)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakglobant committed Apr 23, 2024
1 parent c7033d0 commit 806370e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 10 additions & 1 deletion packages/camera/src/components/Capture/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const Capture = forwardRef(({
onReady,
onStartUploadPicture,
onFinishUploadPicture,
onNavigateToNextSight,
orientationBlockerProps,
overlayPathStyles,
primaryColor,
Expand Down Expand Up @@ -353,6 +354,12 @@ const Capture = forwardRef(({
}
}, [setAddDamageStatus, lastAddDamageHelpTimestamp]);

const handleOnFinishUploadPicture = useCallback(async () => {
await onNavigateToNextSight();
api.goNextSight();
onFinishUploadPicture();
}, [api]);

const handleResetDamageStatus = useCallback(() => {
setAddDamageStatus(AddDamageStatus.IDLE);
setAddDamageParts([]);
Expand Down Expand Up @@ -611,7 +618,7 @@ const Capture = forwardRef(({
onCloseEarly={handleCloseEarlyClick}
onAddDamagePressed={handleAddDamagePressed}
onStartUploadPicture={onStartUploadPicture}
onFinishUploadPicture={onFinishUploadPicture}
onFinishUploadPicture={handleOnFinishUploadPicture}
addDamageParts={addDamageParts}
onResetAddDamageStatus={handleResetDamageStatus}
hideAddDamage={hideAddDamage}
Expand Down Expand Up @@ -858,6 +865,7 @@ Capture.propTypes = {
onComplianceCheckFinish: PropTypes.func,
onComplianceCheckStart: PropTypes.func,
onFinishUploadPicture: PropTypes.func,
onNavigateToNextSight: PropTypes.func,
onPictureTaken: PropTypes.func,
onPictureUploaded: PropTypes.func,
onReady: PropTypes.func,
Expand Down Expand Up @@ -979,6 +987,7 @@ Capture.defaultProps = {
onComplianceCheckFinish: () => { },
onComplianceCheckStart: () => { },
onFinishUploadPicture: () => { },
onNavigateToNextSight: () => { },
onWarningMessage: () => { },
onReady: () => { },
onStartUploadPicture: () => { },
Expand Down
2 changes: 0 additions & 2 deletions packages/camera/src/components/Controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,10 @@ export default function Controls({
if (action === Actions.sights.ADD_PROCESS_TO_QUEUE) {
if (noOfProcesses < MAX_LIMIT_FOR_PROCESSES && current.index !== (ids.length - 1)) {
onFinishUploadPicture(state, api);
api.goNextSight();
}
} else if (action === Actions.sights.REMOVE_PROCESS_FROM_QUEUE) {
if (noOfProcesses === (MAX_LIMIT_FOR_PROCESSES - 1) && current.index !== (ids.length - 1)) {
onFinishUploadPicture(state, api);
api.goNextSight();
}
}
}, [state.sights.state.process]);
Expand Down
7 changes: 7 additions & 0 deletions website/docs/js/api/components/Capture.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function Inspector({ inspectionId }) {
onReady={() => setLoading(false)}
onStartUploadPicture={() => setLoading(true)}
onFinishUploadPicture={() => setLoading(false)}
onNavigateToNextSight={onNavigateToNextSight}
onChange={handleChange}
sightIds={Constants.defaultSightIds}
/>
Expand Down Expand Up @@ -93,6 +94,7 @@ export default function Inspector({ inspectionId }) {
onReady={() => setLoading(false)}
onStartUploadPicture={() => setLoading(true)}
onFinishUploadPicture={() => setLoading(false)}
onNavigateToNextSight={onNavigateToNextSight}
onChange={handleChange}
sightIds={Constants.defaultSightIds}
/>
Expand Down Expand Up @@ -468,6 +470,11 @@ const handleStartUploadPicture = (state, api) => console.log('Started uploading

Will call a function when the uploading is finished for every picture.

## onNavigateToNextSight
`PropTypes.func`

Will call a function before navigating to next sight.

```js
const handleFinishUploadPicture = (state, api) => console.log('Finished uploading a picture');
```
Expand Down

0 comments on commit 806370e

Please sign in to comment.