Skip to content

Commit

Permalink
Uso del conversor
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoRedondoo committed May 14, 2024
1 parent cb9cb89 commit 448d7bb
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 14 deletions.
125 changes: 125 additions & 0 deletions front/src/routes/integrations/changeNRM/+page.svelte
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>
127 changes: 127 additions & 0 deletions front/src/routes/integrations/chatbotNRM/+page.svelte
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>


31 changes: 17 additions & 14 deletions front/src/routes/integrations/nbaGamesNRM/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
<script>
import axios from 'axios';
import { Container, Button, Input, ListGroup, ListGroupItem, Row, Col} from '@sveltestrap/sveltestrap';
let inputSeason;
let inputTeam;
let games = [];
async function fetchNBAGamesData() {
const params = new URLSearchParams({
season: inputSeason,
team: inputTeam
});
const url = `https://api-nba-v1.p.rapidapi.com/games?${params}`;
const options = {
method: 'GET',
url: 'https://api-nba-v1.p.rapidapi.com/games',
params: {
season: inputSeason,
team: inputTeam
},
headers: {
'X-RapidAPI-Key': '88a523cd96msh3544e0ee37800ebp1845b1jsnf31a7971dadb',
'X-RapidAPI-Host': 'api-nba-v1.p.rapidapi.com'
}
};
try {
const response = await axios.request(options);
console.log(response.data);
games = response.data.response;
console.log(response.data.response);
console.log(games.length);
const response = await fetch(url, options);
if (response.ok) {
const data = await response.json();
console.log(data);
games = data.response;
console.log(games);
console.log(games.length);
} else {
throw new Error('Error al obtener los datos');
}
} catch (error) {
console.error(error);
console.error(error);
}
}
Expand Down
Binary file added front/static/ia.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 448d7bb

Please sign in to comment.