import { Alert } from "react-native"; // Lodash import _ from 'lodash'; // Http Client import axios from 'axios'; // Network Infos import NetInfo from "@react-native-community/netinfo"; // Translations import i18n from "../../I18n"; // Database import { Setting } from "../../Database"; const api_token = 'G9Q62jt8eL8gN4Ls'; class InstallController { async getConfig(url) { return axios({ method: 'GET', url: url + '/api/settings', responseType: 'json', params: { token: api_token }, }); } getAppConfig(url) { NetInfo.fetch().then(state => { if (state.isConnected) { axios({ method: 'GET', url: url + '/api/app', responseType: 'json', params: { token: api_token }, }) .then(function (response) { if (response.data) { if (response.data.status === "OK") { Setting.upsert({ key: 'HomeFolders', value: JSON.stringify(response.data.datas.folders) }); } else { Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred")); return false; } } }) .catch(function (error) { console.log(error) Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred")); return false; }) } else { Alert.alert(i18n.t("alert.error"), i18n.t("error.tablet_not_connected_internet")); return false; } }); return true; } } export default new InstallController();