import { PermissionsAndroid, Platform } from 'react-native';
// import { NetworkInfo } from 'react-native-network-info';

import i18n from '~/locale/i18n';

export default () => ({
	async getWiFiSSID() {
		return new Promise(async (resolve, reject) => {
			if (Platform.os === 'android') {
				try {
					const granted = await PermissionsAndroid.request(
						PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
						{
							title: i18n.t('common.wifiNetwork'),
							message: i18n.t('common.weNeedYourPermissionInOrderToFindWifiNetworks'),
						},
					);
					if (granted === PermissionsAndroid.RESULTS.GRANTED) {
						// NetworkInfo.getSSID((ssid) => {
						// 	resolve(ssid);
						// });
					} else {
						reject(new Error('You will not able to retrieve wifi available networks list'));
					}
				} catch (err) {
					reject(err);
				}
			} else {
				// NetworkInfo.getSSID((ssid) => {
				// 	if (ssid === 'error') {
				// 		reject(ssid);
				// 	} else {
				// 		resolve(ssid);
				// 	}
				// });
			}
		});
	},
});
