-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb9cb89
commit 448d7bb
Showing
4 changed files
with
269 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<script> | ||
import { onMount } from "svelte"; | ||
import { Container, Row, Input, Col, Button } from "@sveltestrap/sveltestrap"; | ||
let change; | ||
let currencyList = []; | ||
let inputAmount; | ||
let selectedCurrencyFrom; | ||
let selectedCurrencyTo; | ||
let result =0; | ||
async function getCurrencies() { | ||
const options = { | ||
method: 'GET', | ||
headers: { | ||
'X-RapidAPI-Key': '88a523cd96msh3544e0ee37800ebp1845b1jsnf31a7971dadb', | ||
'X-RapidAPI-Host': 'currency-exchange.p.rapidapi.com' | ||
} | ||
}; | ||
try { | ||
const response = await fetch('https://currency-exchange.p.rapidapi.com/listquotes', options); | ||
if (response.ok) { | ||
const result = await response.json(); | ||
console.log(result); | ||
currencyList = result; | ||
console.log(currencyList); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
async function getChange(){ | ||
const options = { | ||
method: 'GET', | ||
headers: { | ||
'X-RapidAPI-Key': '88a523cd96msh3544e0ee37800ebp1845b1jsnf31a7971dadb', | ||
'X-RapidAPI-Host': 'currency-exchange.p.rapidapi.com' | ||
} | ||
}; | ||
try { | ||
const response = await fetch(`https://currency-exchange.p.rapidapi.com/exchange?from=${selectedCurrencyFrom}&to=${selectedCurrencyTo}&q=1.0`, options); | ||
if (response.ok) { | ||
const data = await response.json(); | ||
change=data; | ||
console.log('Cambio ->'+change); | ||
console.log('Cantidad-> '+inputAmount); | ||
console.log(inputAmount * change); | ||
result = inputAmount * change | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
onMount(() => { | ||
getCurrencies(); | ||
}); | ||
</script> | ||
|
||
<style> | ||
.output { | ||
height: 38px; | ||
width: 100%; | ||
display: flex; | ||
align-items: left; | ||
justify-content: center; | ||
border: solid 1px; | ||
border: 1px solid rgba(0, 0, 0, 0.295); | ||
border-radius: 8px; | ||
} | ||
</style> | ||
|
||
<Container class="converter-container"> | ||
<h1 class="text-center">Money Converter SOS</h1> | ||
|
||
<Row class="my-4"> | ||
<Col sm="4"> | ||
<Input type="number" bind:value={inputAmount} placeholder="Amount" /> | ||
</Col> | ||
<Col sm="2"> | ||
<select class="form-select" bind:value={selectedCurrencyFrom}> | ||
{#each currencyList as currency} | ||
<option>{currency}</option> | ||
{/each} | ||
</select> | ||
</Col> | ||
<Col sm="1" class="d-flex align-items-center justify-content-center"> | ||
<span>to</span> | ||
</Col> | ||
<Col sm="2"> | ||
<select class="form-select" bind:value={selectedCurrencyTo}> | ||
{#each currencyList as currency} | ||
<option>{currency}</option> | ||
{/each} | ||
</select> | ||
</Col> | ||
<Col sm="3" class="d-flex align-items-center justify-content-center "> | ||
<div class="output">{result}</div> | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col sm="12" class="d-flex justify-content-center mt-3"> | ||
<Button class="btn btn-primary" on:click={getChange}>Convertir</Button> | ||
</Col> | ||
</Row> | ||
</Container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<script> | ||
import axios from 'axios'; | ||
import { Container, Button, Row, ListGroup, ListGroupItem, Col} from '@sveltestrap/sveltestrap'; | ||
import { each } from 'highcharts'; | ||
let question; | ||
// export let chatResponse = []; | ||
let chatResponse ; | ||
async function getResponse() { | ||
const encodedParams = new URLSearchParams(); | ||
encodedParams.set('in', `${question}`); | ||
encodedParams.set('op', 'in'); | ||
encodedParams.set('cbot', '1'); | ||
encodedParams.set('SessionID', 'RapidAPI1'); | ||
encodedParams.set('cbid', '1'); | ||
encodedParams.set('key', 'RHMN5hnQ4wTYZBGCF3dfxzypt68rVP'); | ||
encodedParams.set('ChatSource', 'RapidAPI'); | ||
encodedParams.set('duration', '1'); | ||
const options = { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
'X-RapidAPI-Key': '88a523cd96msh3544e0ee37800ebp1845b1jsnf31a7971dadb', | ||
'X-RapidAPI-Host': 'robomatic-ai.p.rapidapi.com' | ||
}, | ||
body: encodedParams | ||
}; | ||
try { | ||
const response = await fetch('https://robomatic-ai.p.rapidapi.com/api', options); | ||
const data = await response.json(); | ||
chatResponse = data.out; | ||
// chatResponse.push(chatResponse,`User: ${question}`); | ||
// chatResponse.push(response.data.out); | ||
console.log (chatResponse); | ||
// console.log(chatResponse.length); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
// onMount(() => { | ||
// getResponse(); | ||
// }) | ||
async function addString() { | ||
try { | ||
chatResponse.push('Hopaaaaa') | ||
console.log(chatResponse); | ||
console.log(chatResponse.length); | ||
} catch (error) { | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
.chat-container { | ||
margin-top: 20px; | ||
border-radius: 20px; | ||
width: 80%; | ||
height: 80%; | ||
margin: auto; | ||
border: solid 3px; | ||
position: absolute; | ||
top: 0; bottom: 0; left: 0; right: 0; | ||
background-image: url('/home/nico/SOS2324-14/front/static/ia.jpeg'); | ||
background-position: center; | ||
padding: 30px; | ||
overflow-y: auto; | ||
display: grid; | ||
align-items: baseline | ||
} | ||
.response { | ||
font-size: 15px; /* Adjust font size as needed */ | ||
text-align: center; | ||
border-radius: 6px; | ||
background-color: aliceblue; | ||
width: 50%; | ||
margin: auto; | ||
opacity: 1; | ||
transition: opacity 1s ease-in-out; /* Center text */ | ||
} | ||
</style> | ||
|
||
<Container> | ||
<!-- <Button class="btn btn-primary" type="button" on:click={addString}>Enviar</Button> --> | ||
<div class="container chat-container"> | ||
<!-- {#if chatResponse.length > 0} | ||
<ListGroup> | ||
{#each chatResponse as response} | ||
<ListGroupItem class="gameItem"> | ||
<Row > | ||
<span class="response" style="border: solid 1px; justify-content: center; border-radius: 10px; background-color: aliceblue;">{response}</span> | ||
</Row> | ||
</ListGroupItem> | ||
{/each} | ||
</ListGroup> | ||
{:else} | ||
<p>Hello! Tell me something</p> | ||
{/if} --> | ||
|
||
{#if chatResponse != undefined} | ||
<span class="response" >{chatResponse}</span> | ||
{/if} | ||
|
||
<div class="input-group mb-3" style="align-self: last baseline;"> | ||
<input type="text" class="form-control" placeholder="Escribe tu mensaje..." bind:value={question}> | ||
<div class="input-group-append"> | ||
<Button class="btn btn-primary" type="button" on:click={getResponse}>Enviar</Button> | ||
</div> | ||
</div> | ||
</div> | ||
</Container> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.