import { Label } from '@widergy/mobile-ui';
import React, { Component, Fragment } from 'react';
import { Image, View } from 'react-native';
import { useBluetoothContext } from '../../bluetooth/useBluetoothContext';
import DeviceDisconnected from '../../ui/assets/bonding/deviceDisconnected.png';
import ReconnectDevice from '../../ui/assets/bonding/reconnectDevice.png';
import Colors from '../Colors';
import GeneralStep from '../GeneralStep';
import styles from './styles';
interface Translations {
title: string;
withoutLinkedDeviceDescription: string;
withoutLinkedDeviceTextButton: string;
withLinkedDeviceDescription: string;
withLinkedDevicePrimaryTextButton: string;
withLinkedDeviceSecondaryTextButton: string;
withLinkedSubtitle: string;
}
interface Props {
reconnectionOrLinkWithProbeTranslations: Translations;
goToProbeProbePairing: Function;
children: Component | Element;
}
const NoProbeWrapper = ({
reconnectionOrLinkWithProbeTranslations: translations,
goToProbeProbePairing,
children,
}: Props) => {
const bluetoothContext = useBluetoothContext();
const targetDevice = bluetoothContext.targetDevice;
if (bluetoothContext.connectionError || (!targetDevice && !bluetoothContext.isConnected())) {
return (
{
bluetoothContext.unlink();
goToProbeProbePairing();
},
key: 'otherDevice',
secondary: true,
},
{
title: translations.withLinkedDevicePrimaryTextButton,
onPress: async () => {
await bluetoothContext.autoConnect().catch(err => console.log({ err }));
},
key: 'lastDevice',
},
]
: [
{
title: translations.withoutLinkedDeviceTextButton,
onPress: () => goToProbeProbePairing(),
key: 'newDevice',
},
]
}
>
{!!targetDevice && (
)}
);
} else {
return {children};
}
};
export default NoProbeWrapper;