import React from 'react';
import { View } from 'react-native';
import type { MockCode } from '../../bluetooth/readMeter';
import type { ReadStrategy } from '../../parsing/ReadStrategy';
import InteractionWithProbe from './components/InteractionWithProbe';
import styles from './styles';
import NoProbeWrapper from '../NoProbeWrapper';

interface StepsTranslations {
  cancelResetTextButton: string;
  meterFamilyTypePrepositionBadge: string;
  readyToResetDescription: string;
  readyToResetTitle: string;
  resetError: string;
  resettingToZeroTitle: string;
  resettingToZeroDescription: string;
  timeoutError: string;
}

interface ReadingTimeouts {
  maxWaitTimePerProbeInteraction: number;
  probeReadingTimeoutInMilliseconds: number;
}

interface Props {
  onClose: Function;
  translations: StepsTranslations;
  onSuccess: Function;
  loadingCurrentDevice: boolean;
  mockCode?: MockCode;
  readStrategy: ReadStrategy;
  reconnectionOrLinkWithProbeTranslations: any;
  goToProbeProbePairing: Function;
  readingDisabled: boolean;
  recoverMeterNumber?: Function | undefined;
  skipReadingResult?: boolean | undefined;
  children?: any;
  timeoutRef?: any;
  readingTimeouts?: ReadingTimeouts | undefined;
  skipResettingError: boolean | undefined;
  showFamilyBadgeLibrary: boolean;
}

const MeterReset = ({
  children,
  onClose,
  loadingCurrentDevice,
  mockCode,
  onSuccess,
  readingTimeouts,
  readStrategy,
  timeoutRef,
  translations,
  goToProbeProbePairing,
  reconnectionOrLinkWithProbeTranslations,
  showFamilyBadgeLibrary = true,
}: Props) => {
  const meterFamilyType = readStrategy.name;

  return (
    <NoProbeWrapper
      reconnectionOrLinkWithProbeTranslations={reconnectionOrLinkWithProbeTranslations}
      goToProbeProbePairing={goToProbeProbePairing}
    >
      <View style={styles.container}>
        <InteractionWithProbe
          children={children}
          onClose={onClose}
          loadingCurrentDevice={loadingCurrentDevice}
          meterFamilyType={meterFamilyType}
          mockCode={mockCode}
          onSuccess={onSuccess}
          readingTimeouts={readingTimeouts}
          readStrategy={readStrategy}
          timeoutRef={timeoutRef}
          translations={translations}
          showFamilyBadgeLibrary={showFamilyBadgeLibrary}
        />
      </View>
    </NoProbeWrapper>
  );
};

export default MeterReset;
