diff --git a/src/components/currencyConverter.tsx b/src/components/currencyConverter.tsx index f75535e..f675ffd 100644 --- a/src/components/currencyConverter.tsx +++ b/src/components/currencyConverter.tsx @@ -1,148 +1,148 @@ -import React, { useEffect, useState } from 'react'; -import axios from 'axios'; -import { Picker } from '@react-native-picker/picker'; -import { - View, - Text, - TextInput, - Image, - StyleSheet, -} from 'react-native'; +// import React, { useEffect, useState } from 'react'; +// import axios from 'axios'; +// import { Picker } from '@react-native-picker/picker'; +// import { +// View, +// Text, +// TextInput, +// Image, +// StyleSheet, +// } from 'react-native'; -const CurrencyConverter = () => { - const [fromCurrency, setFromCurrency] = useState('USD'); - const [toCurrency, setToCurrency] = useState('INR'); - const [exchangeRate, setExchangeRate] = useState(0); - const [currencies, setCurrencies] = useState([]); - const [amount, setAmount] = useState(1); +// const CurrencyConverter = () => { +// const [fromCurrency, setFromCurrency] = useState('USD'); +// const [toCurrency, setToCurrency] = useState('INR'); +// const [exchangeRate, setExchangeRate] = useState(0); +// const [currencies, setCurrencies] = useState([]); +// const [amount, setAmount] = useState(1); - const convertCurrency = () => { - let result = (amount * exchangeRate).toFixed(2); - return result; - }; +// const convertCurrency = () => { +// let result = (amount * exchangeRate).toFixed(2); +// return result; +// }; - useEffect(() => { - const fetchCurrencies = async () => { - try { - const accessKey = '6d886385174567d5d9bbf0dc'; - const response = await axios.get(`https://v6.exchangerate-api.com/v6/latest/USD`, { - headers: { - Authorization: `Bearer ${accessKey}`, - }, - }); - const data = response.data; - setCurrencies(Object.keys(data.rates)); - setExchangeRate(data.rates[toCurrency]); - } catch (error) { - console.error("Error:", error); - } - }; - fetchCurrencies(); - }, [toCurrency]); +// useEffect(() => { +// const fetchCurrencies = async () => { +// try { +// const accessKey = '6d886385174567d5d9bbf0dc'; +// const response = await axios.get(`https://v6.exchangerate-api.com/v6/latest/USD`, { +// headers: { +// Authorization: `Bearer ${accessKey}`, +// }, +// }); +// const data = response.data; +// setCurrencies(Object.keys(data.rates)); +// setExchangeRate(data.rates[toCurrency]); +// } catch (error) { +// console.error("Error:", error); +// } +// }; +// fetchCurrencies(); +// }, [toCurrency]); - useEffect(() => { - const fetchCurrencies = async () => { - try { - const accessKey = '6d886385174567d5d9bbf0dc'; +// useEffect(() => { +// const fetchCurrencies = async () => { +// try { +// const accessKey = '6d886385174567d5d9bbf0dc'; - const response = await axios.get(`https://v6.exchangerate-api.com/v6/latest/${fromCurrency}`, { - headers: { - Authorization: `Bearer ${accessKey}`, - }, - }); - const data = response.data; - setCurrencies(Object.keys(data.rates)); - setExchangeRate(data.rates[toCurrency]); - } catch (error) { - console.error("Error:", error); - } - }; - fetchCurrencies(); - }, [fromCurrency, toCurrency]); +// const response = await axios.get(`https://v6.exchangerate-api.com/v6/latest/${fromCurrency}`, { +// headers: { +// Authorization: `Bearer ${accessKey}`, +// }, +// }); +// const data = response.data; +// setCurrencies(Object.keys(data.rates)); +// setExchangeRate(data.rates[toCurrency]); +// } catch (error) { +// console.error("Error:", error); +// } +// }; +// fetchCurrencies(); +// }, [fromCurrency, toCurrency]); - return ( - - - Currency Converter - setAmount(parseFloat(text))} - /> - - setFromCurrency(itemValue)} - style={styles.picker} - > - {currencies.map((currency, index) => ( - - ))} - - setToCurrency(itemValue)} - style={styles.picker} - > - {currencies.map((currency, index) => ( - - ))} - - - - {amount} {fromCurrency} = {convertCurrency()} {toCurrency} - - - ); -}; +// return ( +// +// +// Currency Converter +// setAmount(parseFloat(text))} +// /> +// +// setFromCurrency(itemValue)} +// style={styles.picker} +// > +// {currencies.map((currency, index) => ( +// +// ))} +// +// setToCurrency(itemValue)} +// style={styles.picker} +// > +// {currencies.map((currency, index) => ( +// +// ))} +// +// +// +// {amount} {fromCurrency} = {convertCurrency()} {toCurrency} +// +// +// ); +// }; -const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: 'center', - justifyContent: 'center', - backgroundColor: '#fff', - }, - image: { - width: 200, - height: 200, - marginBottom: 20, - }, - text: { - fontSize: 30, - marginBottom: 20, - }, - input: { - width: '80%', - borderColor: 'gray', - borderWidth: 1, - marginBottom: 20, - textAlign: 'center', - borderRadius: 5, - padding: 10, - }, - pickerContainer: { - flexDirection: 'row', - justifyContent: 'space-between', - width: 300, - marginBottom: 150, - alignItems: 'center', - }, - picker: { - flex: 1, - height: 50, - marginHorizontal: 10, - width: 150, - }, - result: { - fontSize: 20, - marginTop: 20, - fontWeight: 'bold', - color: '#700e01', - }, -}); +// const styles = StyleSheet.create({ +// container: { +// flex: 1, +// alignItems: 'center', +// justifyContent: 'center', +// backgroundColor: '#fff', +// }, +// image: { +// width: 200, +// height: 200, +// marginBottom: 20, +// }, +// text: { +// fontSize: 30, +// marginBottom: 20, +// }, +// input: { +// width: '80%', +// borderColor: 'gray', +// borderWidth: 1, +// marginBottom: 20, +// textAlign: 'center', +// borderRadius: 5, +// padding: 10, +// }, +// pickerContainer: { +// flexDirection: 'row', +// justifyContent: 'space-between', +// width: 300, +// marginBottom: 150, +// alignItems: 'center', +// }, +// picker: { +// flex: 1, +// height: 50, +// marginHorizontal: 10, +// width: 150, +// }, +// result: { +// fontSize: 20, +// marginTop: 20, +// fontWeight: 'bold', +// color: '#700e01', +// }, +// }); -export default CurrencyConverter; +// export default CurrencyConverter;