import { Dispatch, SetStateAction } from 'react'; import { MonkApiConfig } from '@monkvision/network'; import { LoadingState } from '@monkvision/common'; import { ComplianceOptions, Sight, TaskName } from '@monkvision/types'; /** * Object containing state management utilities for the PhotoCapture sights. */ export interface PhotoCaptureSightState { /** * The currently selected sight in the PhotoCapture component : the sight that the user needs to capture. */ selectedSight: Sight; /** * Array containing the list of sights that the user has already captured. */ sightsTaken: Sight[]; /** * Callback called when the user manually select a new sight. */ selectSight: (s: Sight) => void; /** * Callback called when the user has taken a picture of a sight. */ takeSelectedSight: () => void; /** * Callback called when a sight needs to be retaken. */ retakeSight: (id: string) => void; /** * Value storing the last picture taken by the user. If no picture has been taken yet, this value is null. */ lastPictureTakenUri: string | null; /** * Callback used to manually update the last picture taken by the user after they take a picture. */ setLastPictureTakenUri: (uri: string) => void; /** * Callback that can be used to retry fetching this state object from the API in case the previous fetch failed. */ retryLoadingInspection: () => void; /** * Boolean indicating if the inspection is completed or not. */ isInspectionCompleted: boolean; /** * Callback used to manually update the completion state of the inspection. */ setIsInspectionCompleted: Dispatch>; /** * Boolean indicating if the inspection is compliant or not. */ isInspectionCompliant: boolean; } /** * Parameters of the usePhotoCaptureSightState hook. */ export interface PhotoCaptureSightsParams { /** * The inspection ID. */ inspectionId: string; /** * The list of sights provided to the PhotoCapture component. */ captureSights: Sight[]; /** * The api config used to communicate with the API. */ apiConfig: MonkApiConfig; /** * Global loading state of the PhotoCapture component. */ loading: LoadingState; /** * Callback called when the last sight has been taken by the user. */ onLastSightTaken: () => void; /** * The options for the compliance conf */ complianceOptions: ComplianceOptions; /** * Callback used to manually update the completion state of the inspection. */ setIsInitialInspectionFetched: (state: boolean) => void; /** * Record associating each sight with a list of tasks to execute for it. If not provided, the default tasks of the * sight will be used. */ tasksBySight?: Record; /** Callback called to show the tutorial when retaking a non Car Coverage compliant sight. */ toggleSightTutorial: () => void; } /** * Custom hook used to manage the state of the PhotoCapture sights. This state is automatically fetched from the API at * the start of the PhotoCapture process in order to allow users to start the inspection where they left it before. */ export declare function usePhotoCaptureSightState({ inspectionId, captureSights, apiConfig, loading, onLastSightTaken, tasksBySight, setIsInitialInspectionFetched, complianceOptions, toggleSightTutorial, }: PhotoCaptureSightsParams): PhotoCaptureSightState;