Skip to content

Commit

Permalink
Fixed conflits with VideoCapture feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dlymonkai committed Jan 13, 2025
1 parent cc09ab8 commit dadbde2
Show file tree
Hide file tree
Showing 22 changed files with 123 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { useTranslation } from 'react-i18next';
import { useMonkAppState } from '@monkvision/common';
import { DamageDisclosure } from '@monkvision/inspection-capture-web';
import { useNavigate } from 'react-router-dom';
import { CaptureWorkflow, VehicleType } from '@monkvision/types';
import styles from './DamageDisclosurePage.module.css';
import { Page } from '../pages';

export function DamageDisclosurePage() {
const navigate = useNavigate();
const { i18n } = useTranslation();
const { config, authToken, inspectionId } = useMonkAppState({
const { config, authToken, inspectionId, vehicleType } = useMonkAppState({
requireInspection: true,
requireWorkflow: CaptureWorkflow.PHOTO,
});

return (
Expand All @@ -24,6 +26,7 @@ export function DamageDisclosurePage() {
inspectionId={inspectionId}
onComplete={() => navigate(Page.PHOTO_CAPTURE)}
lang={i18n.language}
vehicleType={vehicleType ?? VehicleType.SEDAN}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useMonkAppState } from '@monkvision/common';
import { PhotoCapture } from '@monkvision/inspection-capture-web';
import { CaptureWorkflow } from '@monkvision/types';
import { CaptureWorkflow, VehicleType } from '@monkvision/types';
import styles from './PhotoCapturePage.module.css';
import { createInspectionReportLink } from './inspectionReport';

Expand Down Expand Up @@ -36,6 +36,7 @@ export function PhotoCapturePage() {
sights={currentSights}
onComplete={handleComplete}
lang={i18n.language}
vehicleType={vehicleType ?? VehicleType.SEDAN}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { MonkApiConfig } from '@monkvision/network';
import {
AddDamage,
CameraConfig,
CaptureAppConfig,
PhotoCaptureAppConfig,
ComplianceOptions,
CompressionOptions,
DeviceOrientation,
ImageType,
MonkPicture,
VehicleType,
} from '@monkvision/types';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
Expand All @@ -40,7 +41,7 @@ import { CaptureScreen } from '../types';
export interface DamageDisclosureProps
extends Pick<CameraProps<DamageDisclosureHUDProps>, 'resolution' | 'allowImageUpscaling'>,
Pick<
CaptureAppConfig,
PhotoCaptureAppConfig,
| keyof CameraConfig
| 'maxUploadDurationWarning'
| 'useAdaptiveImageQuality'
Expand All @@ -60,6 +61,10 @@ export interface DamageDisclosureProps
* one as the one that created the inspection provided in the `inspectionId` prop.
*/
apiConfig: MonkApiConfig;
/**
* The vehicle type of the inspection.
*/
vehicleType?: VehicleType;
/**
* Callback called when the user clicks on the Close button. If this callback is not provided, the button will not be
* displayed on the screen.
Expand Down Expand Up @@ -98,6 +103,7 @@ export function DamageDisclosure({
useAdaptiveImageQuality = true,
lang,
enforceOrientation,
vehicleType = VehicleType.SEDAN,
...initialCameraConfig
}: DamageDisclosureProps) {
useI18nSync(lang);
Expand Down Expand Up @@ -174,6 +180,7 @@ export function DamageDisclosure({
images,
addDamage,
onValidateVehicleParts: addDamageHandle.handleValidateVehicleParts,
vehicleType,
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { useMemo, useState } from 'react';
import { CaptureAppConfig, Image, ImageStatus, ImageType, VehiclePart } from '@monkvision/types';
import {
PhotoCaptureAppConfig,
Image,
ImageStatus,
ImageType,
VehiclePart,
VehicleType,
} from '@monkvision/types';
import { useTranslation } from 'react-i18next';
import { BackdropDialog } from '@monkvision/common-ui-web';
import { CameraHUDProps } from '@monkvision/camera-web';
Expand All @@ -16,7 +23,7 @@ import { HUDOverlay } from '../../components/HUDOverlay';
*/
export interface DamageDisclosureHUDProps
extends CameraHUDProps,
Pick<CaptureAppConfig, 'addDamage' | 'showCloseButton'> {
Pick<PhotoCaptureAppConfig, 'addDamage' | 'showCloseButton'> {
/**
* The inspection ID.
*/
Expand Down Expand Up @@ -70,6 +77,10 @@ export interface DamageDisclosureHUDProps
* The current images taken by the user (ignoring retaken pictures etc.).
*/
images: Image[];
/**
* The vehicle type of the inspection.
*/
vehicleType: VehicleType;
}

/**
Expand All @@ -82,6 +93,7 @@ export function DamageDisclosureHUD({
lastPictureTakenUri,
mode,
vehicleParts,
addDamage,
onAddDamage,
onAddDamagePartsSelected,
onValidateVehicleParts,
Expand All @@ -94,6 +106,7 @@ export function DamageDisclosureHUD({
handle,
cameraPreview,
images,
vehicleType,
}: DamageDisclosureHUDProps) {
const { t } = useTranslation();
const [showCloseModal, setShowCloseModal] = useState(false);
Expand Down Expand Up @@ -122,6 +135,7 @@ export function DamageDisclosureHUD({
{
<DamageDisclosureHUDElements
mode={mode}
addDamage={addDamage}
vehicleParts={vehicleParts}
onAddDamage={onAddDamage}
onCancelAddDamage={onCancelAddDamage}
Expand All @@ -130,6 +144,7 @@ export function DamageDisclosureHUD({
isLoading={loading.isLoading}
error={loading.error ?? handle.error}
previewDimensions={handle.previewDimensions}
vehicleType={vehicleType}
/>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { CaptureAppConfig, PixelDimensions, VehiclePart } from '@monkvision/types';
import {
PhotoCaptureAppConfig,
PixelDimensions,
VehiclePart,
VehicleType,
} from '@monkvision/types';
import { CaptureMode } from '../../../types';
import { CloseUpShot, PartSelection, ZoomOutShot } from '../../../components';
/**
* Props of the DamageDisclosureHUDElements component.
*/
export interface DamageDisclosureHUDElementsProps extends Pick<CaptureAppConfig, 'addDamage'> {
export interface DamageDisclosureHUDElementsProps extends Pick<PhotoCaptureAppConfig, 'addDamage'> {
/**
* The current mode of the component.
*/
Expand Down Expand Up @@ -41,6 +46,10 @@ export interface DamageDisclosureHUDElementsProps extends Pick<CaptureAppConfig,
* The error that occurred in the DamageDisclosure component. Set this value to `null` if there is no error.
*/
error?: unknown | null;
/**
* The vehicle type of the inspection.
*/
vehicleType: VehicleType;
}

/**
Expand All @@ -66,6 +75,7 @@ export function DamageDisclosureHUDElements(params: DamageDisclosureHUDElementsP
}
return (
<PartSelection
vehicleType={params.vehicleType}
onCancel={params.onCancelAddDamage}
vehicleParts={params.vehicleParts}
onValidateVehicleParts={params.onValidateVehicleParts}
Expand Down
18 changes: 12 additions & 6 deletions packages/inspection-capture-web/src/PhotoCapture/PhotoCapture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@ import {
PhotoCaptureAppConfig,
PhotoCaptureTutorialOption,
Sight,
VehicleType,
} from '@monkvision/types';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { styles } from './PhotoCapture.styles';
import { PhotoCaptureHUD, PhotoCaptureHUDProps } from './PhotoCaptureHUD';
import { useStartTasksOnComplete } from '../hooks';
import {
useComplianceAnalytics,
usePhotoCaptureSightState,
usePhotoCaptureTutorial,
useStartTasksOnComplete,
} from './hooks';
import {
usePictureTaken,
useAddDamageMode,
useUploadQueue,
Expand All @@ -38,6 +33,11 @@ import {
useBadConnectionWarning,
useTracking,
} from '../hooks';
import {
useComplianceAnalytics,
usePhotoCaptureSightState,
usePhotoCaptureTutorial,
} from './hooks';

/**
* Props of the PhotoCapture component.
Expand Down Expand Up @@ -77,6 +77,10 @@ export interface PhotoCaptureProps
* one as the one that created the inspection provided in the `inspectionId` prop.
*/
apiConfig: MonkApiConfig;
/**
* The vehicle type of the inspection.
*/
vehicleType?: VehicleType;
/**
* Callback called when the user clicks on the Close button. If this callback is not provided, the button will not be
* displayed on the screen.
Expand Down Expand Up @@ -138,6 +142,7 @@ export function PhotoCapture({
lang,
enforceOrientation,
validateButtonLabel,
vehicleType = VehicleType.SEDAN,
...initialCameraConfig
}: PhotoCaptureProps) {
useI18nSync(lang);
Expand Down Expand Up @@ -278,6 +283,7 @@ export function PhotoCapture({
onCloseTutorial: closeTutorial,
allowSkipTutorial,
enforceOrientation,
vehicleType,
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { useMemo, useState } from 'react';
import { CaptureAppConfig, Image, ImageStatus, Sight, VehiclePart } from '@monkvision/types';
import {
PhotoCaptureAppConfig,
Image,
ImageStatus,
Sight,
VehiclePart,
VehicleType,
} from '@monkvision/types';
import { useTranslation } from 'react-i18next';
import { BackdropDialog } from '@monkvision/common-ui-web';
import { CameraHUDProps } from '@monkvision/camera-web';
Expand All @@ -10,7 +17,7 @@ import { TutorialSteps } from '../hooks';
import { PhotoCaptureHUDElements } from './PhotoCaptureHUDElements';
import { PhotoCaptureHUDTutorial } from './PhotoCaptureHUDTutorial';
import { CaptureMode } from '../../types';
import { HUDButtons, HUDOverlay } from '../../components';
import { HUDButtons, HUDOverlay, OrientationEnforcer } from '../../components';

/**
* Props of the PhotoCaptureHUD component.
Expand Down Expand Up @@ -111,6 +118,10 @@ export interface PhotoCaptureHUDProps
* The current images taken by the user (ignoring retaken pictures etc.).
*/
images: Image[];
/**
* The vehicle type of the inspection.
*/
vehicleType: VehicleType;
}

/**
Expand Down Expand Up @@ -148,6 +159,7 @@ export function PhotoCaptureHUD({
onNextTutorialStep,
onCloseTutorial,
enforceOrientation,
vehicleType,
}: PhotoCaptureHUDProps) {
const { t } = useTranslation();
const [showCloseModal, setShowCloseModal] = useState(false);
Expand Down Expand Up @@ -193,6 +205,7 @@ export function PhotoCaptureHUD({
sightGuidelines={sightGuidelines}
enableSightGuidelines={enableSightGuidelines}
tutorialStep={currentTutorialStep}
vehicleType={vehicleType}
/>
</div>
{mode !== CaptureMode.ADD_DAMAGE_PART_SELECT && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { CaptureAppConfig, Image, PixelDimensions, Sight, VehiclePart } from '@monkvision/types';
import {
PhotoCaptureAppConfig,
Image,
PixelDimensions,
Sight,
VehiclePart,
VehicleType,
} from '@monkvision/types';
import { TutorialSteps } from '../../hooks';
import { PhotoCaptureHUDElementsSight } from '../PhotoCaptureHUDElementsSight';
import { CloseUpShot, ZoomOutShot, PartSelection } from '../../../components';
Expand All @@ -8,7 +15,7 @@ import { CaptureMode } from '../../../types';
* Props of the PhotoCaptureHUDElements component.
*/
export interface PhotoCaptureHUDElementsProps
extends Pick<CaptureAppConfig, 'enableSightGuidelines' | 'sightGuidelines' | 'addDamage'> {
extends Pick<PhotoCaptureAppConfig, 'enableSightGuidelines' | 'sightGuidelines' | 'addDamage'> {
/**
* The currently selected sight in the PhotoCapture component : the sight that the user needs to capture.
*/
Expand Down Expand Up @@ -73,6 +80,10 @@ export interface PhotoCaptureHUDElementsProps
* The current images taken by the user (ignoring retaken pictures etc.).
*/
images: Image[];
/**
* The vehicle type of the inspection.
*/
vehicleType: VehicleType;
}

/**
Expand Down Expand Up @@ -118,6 +129,7 @@ export function PhotoCaptureHUDElements(params: PhotoCaptureHUDElementsProps) {
<PartSelection
onCancel={params.onCancelAddDamage}
vehicleParts={params.vehicleParts}
vehicleType={params.vehicleType}
onValidateVehicleParts={params.onValidateVehicleParts}
onAddDamagePartsSelected={params.onAddDamagePartsSelected}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { Button } from '@monkvision/common-ui-web';
import { AddDamage, CaptureAppConfig } from '@monkvision/types';
import { AddDamage, PhotoCaptureAppConfig } from '@monkvision/types';
import { useTranslation } from 'react-i18next';
import { getLanguage } from '@monkvision/common';
import { styles } from './SightGuideline.styles';
Expand All @@ -10,7 +10,7 @@ import { useColorBackground } from '../../../../hooks';
* Props of the SightGuideline component.
*/
export interface SightGuidelineProps
extends Pick<CaptureAppConfig, 'addDamage' | 'sightGuidelines' | 'enableSightGuidelines'> {
extends Pick<PhotoCaptureAppConfig, 'addDamage' | 'sightGuidelines' | 'enableSightGuidelines'> {
/**
* The id of the sight.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TutorialSteps } from '../../hooks';
* Props of the PhotoCaptureHUDElementsSight component.
*/
export interface PhotoCaptureHUDElementsSightProps
extends Pick<CaptureAppConfig, 'enableSightGuidelines' | 'sightGuidelines' | 'addDamage'> {
extends Pick<PhotoCaptureAppConfig, 'enableSightGuidelines' | 'sightGuidelines' | 'addDamage'> {
/**
* The list of sights provided to the PhotoCapture component.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useColorBackground } from '../../../hooks';
* Props of the PhotoCaptureHUDTutorial component.
*/
export interface PhotoCaptureHUDTutorialProps
extends Pick<CaptureAppConfig, 'allowSkipTutorial' | 'sightGuidelines' | 'addDamage'> {
extends Pick<PhotoCaptureAppConfig, 'allowSkipTutorial' | 'sightGuidelines' | 'addDamage'> {
/**
* The id of the sight.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './usePhotoCaptureSightState';
export * from './useStartTasksOnComplete';
export * from './useComplianceAnalytics';
export * from './usePhotoCaptureTutorial';
Loading

0 comments on commit dadbde2

Please sign in to comment.